Layout is not calling correctly The Next CEO of Stack OverflowConditionally show/hide blocks in layout XMLcalling css using layout xmlHow to change admin login template in Magento 1.5 or 1.6Calling a function within header.phtmlExclude a specific categorycalling block from another blockBlock type not working in layout/catalog.xmlMagento 2: Custom Module's Frontend Controller not calling layoutcall other layout and block in custom phtmlMagento 1.9.3 calling a custom block in cart page unsuccessful

Grabbing quick drinks

Is a stroke of luck acceptable after a series of unfavorable events?

Term for the "extreme-extension" version of a straw man fallacy?

Anatomically Correct Mesopelagic Aves

Need some help with wall behind rangetop

I believe this to be a fraud - hired, then asked to cash check and send cash as Bitcoin

Return the Closest Prime Number

How to count occurrences of text in a file?

How do I go from 300 unfinished/half written blog posts, to published posts?

How can I open an app using Terminal?

Failed to fetch jessie backports repository

How do scammers retract money, while you can’t?

How to start emacs in "nothing" mode (`fundamental-mode`)

How can I get through very long and very dry, but also very useful technical documents when learning a new tool?

How did people program for Consoles with multiple CPUs?

Increase performance creating Mandelbrot set in python

What can we do to stop prior company from asking us questions?

Why does standard notation not preserve intervals (visually)

How easy is it to start Magic from scratch?

How to write papers efficiently when English isn't my first language?

How to be diplomatic in refusing to write code that breaches the privacy of our users

Describing a person. What needs to be mentioned?

How to write the block matrix in LaTex?

Anatomically Correct Strange Women In Ponds Distributing Swords



Layout is not calling correctly



The Next CEO of Stack OverflowConditionally show/hide blocks in layout XMLcalling css using layout xmlHow to change admin login template in Magento 1.5 or 1.6Calling a function within header.phtmlExclude a specific categorycalling block from another blockBlock type not working in layout/catalog.xmlMagento 2: Custom Module's Frontend Controller not calling layoutcall other layout and block in custom phtmlMagento 1.9.3 calling a custom block in cart page unsuccessful










0















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.










share|improve this question




























    0















    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.










    share|improve this question


























      0












      0








      0








      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.










      share|improve this question
















      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.







      magento-1.9 layout blocks template header






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 1 hour ago









      Shoaib Munir

      2,2991829




      2,2991829










      asked Aug 17 '17 at 5:44









      GeekGeek

      11




      11




















          2 Answers
          2






          active

          oldest

          votes


















          0














           $this->loadLayout(); 
          $this->getResponse()->setBody($this->getLayout()
          ->createBlock('mymodule/measurescreen')
          ->setData('response', $collect)
          ->toHtml());
          $this->renderLayout();


          protected function _construct()

          parent::_construct();
          $this->setTemplate('mymodule/measurescreen.phtml');



          Try this code please






          share|improve this answer























          • Have tried this already. Not working.

            – Geek
            Aug 17 '17 at 8:16











          • change to _toHtml()

            – Vijay-CyberLocker
            Aug 17 '17 at 8:25











          • It gives error. doesn't work

            – Geek
            Aug 17 '17 at 8:46


















          0














          Your code should looks like this:



          app/code/local/Company/Module/controllers/IndexController.php



          <?php
          class Company_Module_IndexController extends Mage_Core_Controller_Front_Action

          public function indexAction()

          $this->loadLayout();
          $this->renderLayout();




          app/code/local/Company/Module/etc/config.xml



          <config>
          ...
          </global>
          <frontend>
          <layout>
          <updates>
          <company_module>
          <file>company_module.xml</file> //we will define your phtml in this file
          </company_module>
          </updates>
          </layout>
          </frontend>
          </config>


          app/design/frontend/packagename/modulename/layout/company_module.xml



          <?xml version="1.0"?>
          <layout>
          <rooterName_index_index>
          <reference name="root">
          <action method="setTemplate">
          <template>page/1column.phtml</template> //or 2columns-left.phtml, ...
          </action>
          </reference>
          <reference name="content">
          <block type="block/type" name="my.block.page" template="custom/measurescreen.phtml" />
          </reference>
          </rooterName_index_index>
          </layout>


          app/design/frontend/packagename/modulename/template/custom/measurescreen.phtml



          <div class="wrapper">Good morning</div>





          share|improve this answer

























          • it is exactly same as you defined.

            – Geek
            Aug 17 '17 at 8:22











          • Not at all look a little your controller and the mine, please try my solution if you want to solve your problem

            – PЯINCƏ
            Aug 17 '17 at 8:25











          • I have edited with complete code of indexcontroller of mine. Please check now. I have done what you mentioned already.

            – Geek
            Aug 17 '17 at 8:42











          • The problem I am facing that to use setTemplate and setData together. Whatever solution I am trying is either displaying perfect layout or my phtml file's content.

            – Geek
            Aug 17 '17 at 8:44












          Your Answer








          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "479"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f189420%2flayout-is-not-calling-correctly%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














           $this->loadLayout(); 
          $this->getResponse()->setBody($this->getLayout()
          ->createBlock('mymodule/measurescreen')
          ->setData('response', $collect)
          ->toHtml());
          $this->renderLayout();


          protected function _construct()

          parent::_construct();
          $this->setTemplate('mymodule/measurescreen.phtml');



          Try this code please






          share|improve this answer























          • Have tried this already. Not working.

            – Geek
            Aug 17 '17 at 8:16











          • change to _toHtml()

            – Vijay-CyberLocker
            Aug 17 '17 at 8:25











          • It gives error. doesn't work

            – Geek
            Aug 17 '17 at 8:46















          0














           $this->loadLayout(); 
          $this->getResponse()->setBody($this->getLayout()
          ->createBlock('mymodule/measurescreen')
          ->setData('response', $collect)
          ->toHtml());
          $this->renderLayout();


          protected function _construct()

          parent::_construct();
          $this->setTemplate('mymodule/measurescreen.phtml');



          Try this code please






          share|improve this answer























          • Have tried this already. Not working.

            – Geek
            Aug 17 '17 at 8:16











          • change to _toHtml()

            – Vijay-CyberLocker
            Aug 17 '17 at 8:25











          • It gives error. doesn't work

            – Geek
            Aug 17 '17 at 8:46













          0












          0








          0







           $this->loadLayout(); 
          $this->getResponse()->setBody($this->getLayout()
          ->createBlock('mymodule/measurescreen')
          ->setData('response', $collect)
          ->toHtml());
          $this->renderLayout();


          protected function _construct()

          parent::_construct();
          $this->setTemplate('mymodule/measurescreen.phtml');



          Try this code please






          share|improve this answer













           $this->loadLayout(); 
          $this->getResponse()->setBody($this->getLayout()
          ->createBlock('mymodule/measurescreen')
          ->setData('response', $collect)
          ->toHtml());
          $this->renderLayout();


          protected function _construct()

          parent::_construct();
          $this->setTemplate('mymodule/measurescreen.phtml');



          Try this code please







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Aug 17 '17 at 8:14









          Vijay-CyberLockerVijay-CyberLocker

          1376




          1376












          • Have tried this already. Not working.

            – Geek
            Aug 17 '17 at 8:16











          • change to _toHtml()

            – Vijay-CyberLocker
            Aug 17 '17 at 8:25











          • It gives error. doesn't work

            – Geek
            Aug 17 '17 at 8:46

















          • Have tried this already. Not working.

            – Geek
            Aug 17 '17 at 8:16











          • change to _toHtml()

            – Vijay-CyberLocker
            Aug 17 '17 at 8:25











          • It gives error. doesn't work

            – Geek
            Aug 17 '17 at 8:46
















          Have tried this already. Not working.

          – Geek
          Aug 17 '17 at 8:16





          Have tried this already. Not working.

          – Geek
          Aug 17 '17 at 8:16













          change to _toHtml()

          – Vijay-CyberLocker
          Aug 17 '17 at 8:25





          change to _toHtml()

          – Vijay-CyberLocker
          Aug 17 '17 at 8:25













          It gives error. doesn't work

          – Geek
          Aug 17 '17 at 8:46





          It gives error. doesn't work

          – Geek
          Aug 17 '17 at 8:46













          0














          Your code should looks like this:



          app/code/local/Company/Module/controllers/IndexController.php



          <?php
          class Company_Module_IndexController extends Mage_Core_Controller_Front_Action

          public function indexAction()

          $this->loadLayout();
          $this->renderLayout();




          app/code/local/Company/Module/etc/config.xml



          <config>
          ...
          </global>
          <frontend>
          <layout>
          <updates>
          <company_module>
          <file>company_module.xml</file> //we will define your phtml in this file
          </company_module>
          </updates>
          </layout>
          </frontend>
          </config>


          app/design/frontend/packagename/modulename/layout/company_module.xml



          <?xml version="1.0"?>
          <layout>
          <rooterName_index_index>
          <reference name="root">
          <action method="setTemplate">
          <template>page/1column.phtml</template> //or 2columns-left.phtml, ...
          </action>
          </reference>
          <reference name="content">
          <block type="block/type" name="my.block.page" template="custom/measurescreen.phtml" />
          </reference>
          </rooterName_index_index>
          </layout>


          app/design/frontend/packagename/modulename/template/custom/measurescreen.phtml



          <div class="wrapper">Good morning</div>





          share|improve this answer

























          • it is exactly same as you defined.

            – Geek
            Aug 17 '17 at 8:22











          • Not at all look a little your controller and the mine, please try my solution if you want to solve your problem

            – PЯINCƏ
            Aug 17 '17 at 8:25











          • I have edited with complete code of indexcontroller of mine. Please check now. I have done what you mentioned already.

            – Geek
            Aug 17 '17 at 8:42











          • The problem I am facing that to use setTemplate and setData together. Whatever solution I am trying is either displaying perfect layout or my phtml file's content.

            – Geek
            Aug 17 '17 at 8:44
















          0














          Your code should looks like this:



          app/code/local/Company/Module/controllers/IndexController.php



          <?php
          class Company_Module_IndexController extends Mage_Core_Controller_Front_Action

          public function indexAction()

          $this->loadLayout();
          $this->renderLayout();




          app/code/local/Company/Module/etc/config.xml



          <config>
          ...
          </global>
          <frontend>
          <layout>
          <updates>
          <company_module>
          <file>company_module.xml</file> //we will define your phtml in this file
          </company_module>
          </updates>
          </layout>
          </frontend>
          </config>


          app/design/frontend/packagename/modulename/layout/company_module.xml



          <?xml version="1.0"?>
          <layout>
          <rooterName_index_index>
          <reference name="root">
          <action method="setTemplate">
          <template>page/1column.phtml</template> //or 2columns-left.phtml, ...
          </action>
          </reference>
          <reference name="content">
          <block type="block/type" name="my.block.page" template="custom/measurescreen.phtml" />
          </reference>
          </rooterName_index_index>
          </layout>


          app/design/frontend/packagename/modulename/template/custom/measurescreen.phtml



          <div class="wrapper">Good morning</div>





          share|improve this answer

























          • it is exactly same as you defined.

            – Geek
            Aug 17 '17 at 8:22











          • Not at all look a little your controller and the mine, please try my solution if you want to solve your problem

            – PЯINCƏ
            Aug 17 '17 at 8:25











          • I have edited with complete code of indexcontroller of mine. Please check now. I have done what you mentioned already.

            – Geek
            Aug 17 '17 at 8:42











          • The problem I am facing that to use setTemplate and setData together. Whatever solution I am trying is either displaying perfect layout or my phtml file's content.

            – Geek
            Aug 17 '17 at 8:44














          0












          0








          0







          Your code should looks like this:



          app/code/local/Company/Module/controllers/IndexController.php



          <?php
          class Company_Module_IndexController extends Mage_Core_Controller_Front_Action

          public function indexAction()

          $this->loadLayout();
          $this->renderLayout();




          app/code/local/Company/Module/etc/config.xml



          <config>
          ...
          </global>
          <frontend>
          <layout>
          <updates>
          <company_module>
          <file>company_module.xml</file> //we will define your phtml in this file
          </company_module>
          </updates>
          </layout>
          </frontend>
          </config>


          app/design/frontend/packagename/modulename/layout/company_module.xml



          <?xml version="1.0"?>
          <layout>
          <rooterName_index_index>
          <reference name="root">
          <action method="setTemplate">
          <template>page/1column.phtml</template> //or 2columns-left.phtml, ...
          </action>
          </reference>
          <reference name="content">
          <block type="block/type" name="my.block.page" template="custom/measurescreen.phtml" />
          </reference>
          </rooterName_index_index>
          </layout>


          app/design/frontend/packagename/modulename/template/custom/measurescreen.phtml



          <div class="wrapper">Good morning</div>





          share|improve this answer















          Your code should looks like this:



          app/code/local/Company/Module/controllers/IndexController.php



          <?php
          class Company_Module_IndexController extends Mage_Core_Controller_Front_Action

          public function indexAction()

          $this->loadLayout();
          $this->renderLayout();




          app/code/local/Company/Module/etc/config.xml



          <config>
          ...
          </global>
          <frontend>
          <layout>
          <updates>
          <company_module>
          <file>company_module.xml</file> //we will define your phtml in this file
          </company_module>
          </updates>
          </layout>
          </frontend>
          </config>


          app/design/frontend/packagename/modulename/layout/company_module.xml



          <?xml version="1.0"?>
          <layout>
          <rooterName_index_index>
          <reference name="root">
          <action method="setTemplate">
          <template>page/1column.phtml</template> //or 2columns-left.phtml, ...
          </action>
          </reference>
          <reference name="content">
          <block type="block/type" name="my.block.page" template="custom/measurescreen.phtml" />
          </reference>
          </rooterName_index_index>
          </layout>


          app/design/frontend/packagename/modulename/template/custom/measurescreen.phtml



          <div class="wrapper">Good morning</div>






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Aug 17 '17 at 8:22

























          answered Aug 17 '17 at 8:14









          PЯINCƏPЯINCƏ

          8,39131145




          8,39131145












          • it is exactly same as you defined.

            – Geek
            Aug 17 '17 at 8:22











          • Not at all look a little your controller and the mine, please try my solution if you want to solve your problem

            – PЯINCƏ
            Aug 17 '17 at 8:25











          • I have edited with complete code of indexcontroller of mine. Please check now. I have done what you mentioned already.

            – Geek
            Aug 17 '17 at 8:42











          • The problem I am facing that to use setTemplate and setData together. Whatever solution I am trying is either displaying perfect layout or my phtml file's content.

            – Geek
            Aug 17 '17 at 8:44


















          • it is exactly same as you defined.

            – Geek
            Aug 17 '17 at 8:22











          • Not at all look a little your controller and the mine, please try my solution if you want to solve your problem

            – PЯINCƏ
            Aug 17 '17 at 8:25











          • I have edited with complete code of indexcontroller of mine. Please check now. I have done what you mentioned already.

            – Geek
            Aug 17 '17 at 8:42











          • The problem I am facing that to use setTemplate and setData together. Whatever solution I am trying is either displaying perfect layout or my phtml file's content.

            – Geek
            Aug 17 '17 at 8:44

















          it is exactly same as you defined.

          – Geek
          Aug 17 '17 at 8:22





          it is exactly same as you defined.

          – Geek
          Aug 17 '17 at 8:22













          Not at all look a little your controller and the mine, please try my solution if you want to solve your problem

          – PЯINCƏ
          Aug 17 '17 at 8:25





          Not at all look a little your controller and the mine, please try my solution if you want to solve your problem

          – PЯINCƏ
          Aug 17 '17 at 8:25













          I have edited with complete code of indexcontroller of mine. Please check now. I have done what you mentioned already.

          – Geek
          Aug 17 '17 at 8:42





          I have edited with complete code of indexcontroller of mine. Please check now. I have done what you mentioned already.

          – Geek
          Aug 17 '17 at 8:42













          The problem I am facing that to use setTemplate and setData together. Whatever solution I am trying is either displaying perfect layout or my phtml file's content.

          – Geek
          Aug 17 '17 at 8:44






          The problem I am facing that to use setTemplate and setData together. Whatever solution I am trying is either displaying perfect layout or my phtml file's content.

          – Geek
          Aug 17 '17 at 8:44


















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Magento Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f189420%2flayout-is-not-calling-correctly%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Nidaros erkebispedøme

          Birsay

          Where did Arya get these scars? Unicorn Meta Zoo #1: Why another podcast? Announcing the arrival of Valued Associate #679: Cesar Manara Favourite questions and answers from the 1st quarter of 2019Why did Arya refuse to end it?Has the pronunciation of Arya Stark's name changed?Has Arya forgiven people?Why did Arya Stark lose her vision?Why can Arya still use the faces?Has the Narrow Sea become narrower?Does Arya Stark know how to make poisons outside of the House of Black and White?Why did Nymeria leave Arya?Why did Arya not kill the Lannister soldiers she encountered in the Riverlands?What is the current canonical age of Sansa, Bran and Arya Stark?