I am creating a custom module, everything is working fine but on view page, My phtml file calling first and then header is coming.
I am calling and setting data like this :
IndexController.php
class MagePeople_Mymodule_IndexController extends Mage_Core_Controller_Front_Action
{
public function indexAction()
{
$this->loadLayout();
$this->renderLayout();
}
public function editMeasurementAction()
{
$customer = Mage::getSingleton('customer/session')->getCustomer();
$customerId = $customer->getId();
$proid = $this->getRequest()->getParam('proid');
$collection = Mage::getModel('mymodule/usermeasurement')->getCollection();
$collection->addFieldToFilter( 'product_id', $proid );
$collection->addFieldToFilter( 'user_id', $customerId );
$collection->getFirstItem()->getData();
foreach ($collection as $collect) {
$response[] = array(
'proid' => $collect->getProductId(),
'stnd_size' => $collect->getStndSize()
);
}
$this->loadLayout();
$this->getResponse()
->setBody($this->getLayout()
->createBlock('mymodule/measurescreen')
->setData('response', $collect)
->toHtml());
$this->renderLayout();
}
}
Block file function is below :
protected function _construct()
{
$this->setTemplate('mymodule/measurescreen.phtml');
}
I am not sure how to call block and set and retrieve data if I follow another approach. Can someone please tell me what is wrong in this and why it is showing like this.