使用Magento我在类中定义了一个变量:
在app / code / local / Me / MyMod / Helper / Data.php
中class Me_MyMod_Helper_Data extends Mage_Core_Helper_Abstract
{
public $theVar = 'I want this';
}
然后在app / design / frontend / Me / some.phtml视图中如何获取此变量?
Mage::helper('MyMod')->iDontKnowWhatIamDoing;
答案 0 :(得分:1)
class Me_MyMod_Helper_Data extends Mage_Core_Helper_Abstract
{
public $theVar = 'I want this';
public function send_to_template() {
return $this->theVar;
}
}
在模板中:
Mage::helper('MyMod')->send_to_template();
答案 1 :(得分:0)
在Data.php中写下以下函数
class Me_MyMod_Helper_Data extends Mage_Core_Helper_Abstract
{
public function getThis()
{
$theVar = 'I want this';
return $theVar;
}
}
使用以下代码调用您的变量
echo Mage::helper('MyMod')->getThis();