Magento Forum

   
Display leftcol callout only on homepage? 
 
Tweakmag
Guru
 
Avatar
Total Posts:  307
Joined:  2007-08-31
London, UK
 

Hi there,
Is there an easy way in the xml to hide the leftcol callout on all pages except the homepage?

Cheers.
Adam

 
Magento Community Magento Community
Magento Community
Magento Community
 
Moshe
Magento Team
 
Avatar
Total Posts:  1770
Joined:  2007-08-07
Los Angeles
 

The left column on home page is in this specific page html, so when you are editing the html, just update in the beginning of html:

<div class="col-left side-col">
<!-- 
add this -->
  
{{block type="core/template" template="callouts/left_col.phtml"}}
<!-- until here -->

It is also possible to have every CMS page to have it’s own layout update:

1. run on your database:

alter table `cms_pageadd column `layout_update_xmltext;

2. add this code in app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Main.php on approx. line 104:

$fieldset->addField('layout_update_xml''editor', array(
  
'name' => 'layout_update_xml',
  
'label' => __('Layout Update XML'),
  
'style' => 'width:98%'
));

3. update app/code/core/Mage/Cms/Helper/Page.php on approx. line 51:
replace:

$action->loadLayout();
with:
$action->loadLayout(nullfalsefalse);
$action->getLayout()->getUpdate()->addUpdate($page->getLayoutUpdateXml());
$action->generateLayoutXml()->generateLayoutBlocks();

Now you can put in new field that you will see when editing CMS page on the bottom things like:

<reference name="left">
  <
block type="core/template" template="callouts/left_col.phtml"/>
</
reference>

 
Magento Community Magento Community
Magento Community
Magento Community
 
Garri
Jr. Member
 
Avatar
Total Posts:  30
Joined:  2007-09-18
 

"Layout Update XML” implemented with Magento ver. 0.6.13700, works good, but not always works correctly.

this code prints nothing (My bad?):

<reference name="left">
  <
block type="core/template" template="callouts/left_col.phtml"/>
</
reference>
and for example, next code it like this prints content as well as at the very end of the page, after HTML tag. (double print ?)
<reference name="content">
  <
block type="core/template" template="home/home.phtml"/>
</
reference>

And I think the field “Content” should not be required to fill

 
Magento Community Magento Community
Magento Community
Magento Community
 
Moshe
Magento Team
 
Avatar
Total Posts:  1770
Joined:  2007-08-07
Los Angeles
 

@Garri: Please try:

<reference name="left">
  <
block type="core/template" name="left.callout" template="callouts/left_col.phtml"/>
</
reference>
and
<reference name="content">
  <
block type="core/template" name="home.block" template="home/home.phtml"/>
</
reference>
I’ll check why no name makes problems.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Garri
Jr. Member
 
Avatar
Total Posts:  30
Joined:  2007-09-18
 

Yes, with attr. `name` works better:  no prints after HTML tag.
I checked in conjunction with the layout templates.

for the first case (left_col):

empty: no output
one_column: no output
left_column: 2 outputs on left_col
right_column: no output
three_column: 2 outputs on left_col

and for the second case (content):

empty: 1 output at content
one_column: 1 output at content
left_column: 1 output at content
right_column: 1 output at content
three_column: 1 output at content

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top