I need to get data from url and pass it block method for some operation.
Basically i need to list some content on specific id in magento.
my controller function is
----------------------------
public function showArchiveAction() {
$id = $this->getRequest()->getParams('o');
$this->loadLayout();
$this->renderLayout();
}
my block method
----------------
public function getMagazine($id)
{
$defaultMagazine = Mage::getModel('magazine/display')->getCollection()->load($id);
$data = $defaultMagazine->getData();
$defaultMagazineId = $data[0]['magazine_id'];
$collection = Mage::getModel('magazine/page')->getCollection()->addFieldToFilter('magazine_id',$defaultMagazineId);
return $collection;
}
Best Answer
It seams like you are getting the id right.
You have 2 options here to send the data to the block.
Option 1 - Using
register
.Then you can read the id in the block or the template:
Option 2 - assigning the id to the block.
For this approach let's say that you block has the name
magazine_details
in the layout.Then you can read this value in the block or template like this: