Answer the question
In order to leave comments, you need to log in
How can I pass a value from one function to another?
The code:
<?php
class Page_Portfolio extends Page_Basic
{
function actionIndex() {
$cms_class = cms_class::getInstance();
$sql = "SELECT * FROM site_portfoliotheme WHERE portfoliotheme_active='Y'";
$menu = $cms_class->getRecords($sql, 3);
$sql = "SELECT * FROM site_portfolio WHERE portfolio_active='Y' ORDER BY portfolio_id DESC";
$viewportf = $cms_class->getRecords($sql, 150, "portfolio_image");
return array("menu"=>$menu, "viewportf"=>$viewportf);
}
function actionHtml()
{
$cms_class = cms_class::getInstance();
$sql = "SELECT * FROM site_portfolio WHERE portfolio_active='Y' AND portfolio_theme='".Router::$pageParams["html"]."'";
$records = $cms_class->getRecords($sql, 150, "portfolio_image");
return array("records"=>$records, "menu"=>$menu);
}
}
Answer the question
In order to leave comments, you need to log in
you can create a $menu property and access it via $this
<?php
class Page_Portfolio extends Page_Basic{
private $menu;
public function actionIndex() {
$this->menu;
}
public function actionHtml(){
$this->menu;
}
}
<?php
class Page_Portfolio extends Page_Basic{
public function actionIndex() {
}
public function actionHtml(){
$this->actionIndex();
}
}
If closer to OOP, then like this, perhaps:
<?php
<?php
class Page_Portfolio extends Page_Basic
{
function actionIndex() {
$sql = "SELECT * FROM site_portfolio WHERE portfolio_active='Y' ORDER BY portfolio_id DESC";
$viewportf = cms_class::getInstance()->getRecords($sql, 150, "portfolio_image");
return array("menu"=>$this->getMenu(), "viewportf"=>$viewportf);
}
function getMenu() {
$cms_class = cms_class::getInstance();
return $cms_class->getRecords($sql, 3);
}
function actionHtml() {
$cms_class = cms_class::getInstance();
$sql = "SELECT * FROM site_portfolio WHERE portfolio_active='Y' AND portfolio_theme='".Router::$pageParams["html"]."'";
$records = $cms_class->getRecords($sql, 150, "portfolio_image");
return array("records"=>$records, "menu"=>$this->getMenu());
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question