Question

I have created one custom banner, I have added banner block in cms home page in that place I have provided banner id.

How to get that banner id in phtml file?

{{block type="simplebanner/simplebanner" name="simplebannercmsblock" template="simplebanner/simplebanner.phtml" banner_id = "1"}}

I need to get banner id in simplebanner.phtml file

my block file having below code

public function _prepareLayout() {
    return parent::_prepareLayout();
}

public function getSimplebanner() {
    if (!$this->hasData('simplebanner')) {
        $this->setData('simplebanner', Mage::registry('simplebanner'));
    }
    return $this->getData('simplebanner');
}

public function getCollection() {

    $_collection = Mage::getModel('simplebanner/simplebanner')->getCollection()->addFieldToFilter('status', 1);
    return $_collection;
}
Was it helpful?

Solution

You will get data by using this

echo $this->banner_id;

OTHER TIPS

Try this

$this->getData('banner_id');

Try:

$this->getBannerId(); // in Block

$this->getLayout()->getBlock('simplebanner')->getBannerId(); // in Controller
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top