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
Horror movie/show or scene where a horse creature opens its mouth really wide and devours a man in a stables
How to count occurrences of text in a file?
Can a caster that cast Polymorph on themselves stop concentrating at any point even if their Int is low?
Was a professor correct to chastise me for writing "Prof. X" rather than "Professor X"?
Only print output after finding pattern
If the heap is initialized for security, then why is the stack uninitialized?
How can I get through very long and very dry, but also very useful technical documents when learning a new tool?
Is it safe to use c_str() on a temporary string?
Implement the Thanos sorting algorithm
Return the Closest Prime Number
How do we know the LHC results are robust?
How does practicing restraint and performing actions of merit purify the mind?
How to write the block matrix in LaTex?
Why doesn't a table tennis ball float on the surface? How do we calculate buoyancy here?
Shade part of a Venn diagram
Why does C# sound extremely flat when saxophone is tuned to G?
MAZDA 3 2006 (UK) - poor acceleration then takes off at 3250 revs
How to be diplomatic in refusing to write code that breaches the privacy of our users
How do scammers retract money, while you can’t?
Would this house-rule that treats advantage as a +1 to the roll instead (and disadvantage as -1) and allows them to stack be balanced?
Robert Sheckley short story about vacation spots being overwhelmed
What does this shorthand mean?
Unreliable Magic - Is it worth it?
What is the purpose of the Evocation wizard's Potent Cantrip feature?
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
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
add a comment |
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
add a comment |
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
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
magento-1.9 layout blocks template header
edited 1 hour ago
Shoaib Munir
2,2991829
2,2991829
asked Aug 17 '17 at 5:44
GeekGeek
11
11
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
$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
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
add a comment |
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>
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
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
$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
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
add a comment |
$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
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
add a comment |
$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
$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
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
add a comment |
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
add a comment |
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>
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
add a comment |
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>
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
add a comment |
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>
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>
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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