Static block at the end of the page Magento - magento

Move the static block at the end of the page. I searched a lot for solution. But, no luck.
I tried swapping of echo in catalog/category/view.phtml. But it did not work.
<?php echo $this->getCmsBlockHtml() ?> <?php echo $this->getProductListHtml() ?>
I do not want to use css to move the block at the end of the page, It creates other alignment issues.
How to go about this problem?

you can use
before and after attributes but only work in one of two cases
When you insert into a core/text_list block
When your template block calls getChildHtml without any paramaters
When you do like this
<reference name="root">
<block type="core/template" name="your_block" before="content" template="page/html/your-block.phtml"/>
</reference>
you're telling Magento
Hey Magento, put the example_block inside the root block.
those blocks are being explicitly rendered.
<?php echo $this->getChildHtml('example_block') ?>
However, there's two cases where order matters. First, if you call
<?php echo $this->getChildHtml() ?>
hope this will sure help you.

swapping of echo work in magento. I will be :-
<?php elseif($this->isMixedMode()): ?>
<?php echo $this->getProductListHtml() ?>
<?php echo $this->getCmsBlockHtml() ?>
Please check the theme, where you are editing
file. File Path should be:- app/design/frontend/default/your theme/template/catalog/category/view.phtml

Related

Magento 1.9: Add custom block to header

I have this in my local.xml.
<reference name="header">
<block type="core/template" name="wc-customheadblock" template="wc-customheadblock.phtml" />
</reference>
Inside wc-customheadblock.phtml i have:
<div style="height:100px; background-color:green">
<h1>This is the wc custom head block</h1>
</div>
But this block is not appearing in the header. I've tried the same for the sidebars (by changing the xml reference name) and it works just fine. Why does this not work for the header?
This site claims its possible to make add blocks to the header using local.xml!
http://www.classyllama.com/development/magento-development/the-better-way-to-modify-magento-layout
Go to your header.phtml file (app/design/frontend/package/theme/page/html/header.phtml) and place one of the following lines:
<?php echo $this->getChildHtml(); ?>
or
<?php echo $this->getChildHtml('wc-customheadblock'); ?>
Most likely header doesn't render child blocks by default because it would cause some template crashes. On the sidebars, extra childs can be easily appended at the end.

Moving Magento "Add to Cart" button to new file not working

I want to move Add to cart button from view.phtml file to 2columns-right.phtml file and I am cant make it work. What I did is that I copied <?php echo $this->getChildHtml('addtocart') ?> from view.phtml file to 2columns-right.phtml and it does not appear at all. I did Flush Magento cache too but nothing again.
Any suggestions on how to make this work?
You should get familiar with magento layout system. To make possible <?php echo $this->getChildHtml('addtocart') ?> work in 2columns-right.phtml this block should be declared as child block of root block (the root is the block that is rendered with 2columns-right.phtml). Actually, I don't see much sense in moving add to cart to other template, because addtocart.phtml itself is just a button that submits whole form that is located at catalog/product/view.phtml. If you take it out of there it won't work.
First of all i agree with nevermourn you can not get childhtml if you havn't declared it. But you can use
<?php echo $this->getLayout()->createBlock('catalog/product_view')->setTemplate('catalog/product/view/addtocart.phtml')->toHtml(); ?>
By using this in 2columns-right.phtml you will get addtocart.phtml for sure.
in order to call add to cart button by using
<?php echo $this->getChildHtml('addtocart') ?>
on the page you desire in layout/local.xml
<yourModule_YourController_yourAction>
<reference name="content">
<block type="catalog/product_view" name="product.info.addtocart" as="addtocart" template="catalog/product/view/addtocart.phtml"/>
</reference>
</yourModule_YourController_yourAction>

Magento block file is not showing up some times

Catalog.xml
<default>
<!-- Mage_Catalog -->
<reference name="top.menu">
<block type="catalog/navigation" name="catalog.topnav" template="catalog/navigation/top.phtml">
<block type="catalog/navigation" name="topnav_extra" template="catalog/navigation/top_extra.phtml" />
</block>
</reference>
top_extra.phtml
<ul>
<li> Custom Menu1 </li>
<li> Custom Menu2 </li>
</ul>
top.phtml
<?php if($_menu): ?>
<ul id="topnav">
<?php echo $_menu ?>
<!-- Header Menu laset tab start here -->
<?php echo $this->getChildHtml('topnav_extra'); ?>
</ul>
This block is not showing sometimes when i refreshing twice or thrice it's coming. I am doing reindexing and cache refreshing on daily using cron. But i dont know why its coming randomly?
That sounds like a caching issue to me. Try calling your custom menu via PHP instead of XML
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('block_id')- >toHtml(); ?>
This will alleviate any issues you might encounter using the XML files. Hope this helps!
<?php echo $this->getLayout()->createBlock('core/template')->setTemplate('catalog/navigation/top_extra.phtml')->toHtml(); ?>
i include that file with out layout handles. I am not sure is the right way to do this? but its showing up. I put log to know how many times its not showing up.. Will see

How to not have the Welcome Message cached in Magento

I'm trying to not have my "Welcome Message" on Magento Cart header cached by my full page cache module. Everything I've tried has led to complete failure. There has to be a way.
I'm using Magentos persistent cart option and I've discovered there is some difference in the welcome message with this option that the module developers may not have accounted for. Don't know really.
It's kind of like the "welcome message is it own module but in another way it's not, It's kind of a php one line on the header page.
Now my fpc module has an option in administration to exclude modules from being cached but you have to give the modules "name" You know i.e. name="some_name". The welcome message isn't like the rest of the other modules that I can tell. Here is the php in the header:
<p class="welcome-msg"><?php echo $this->getWelcome() ?> <?php echo $this->getAdditionalHtml() ?></p>
There is nothing in the parentheses, so I've been trying to give this welcome message a name. I don't know how else to do it.
So I created a static block in adminisration with this in it:
{{block type="core/template" name"header.welcome" as="welcome" template="page/html/welcome.phtml"}}
Then I created a phtml file called welcome.phtml with this in it:
<p class="welcome-msg"><?php echo $this->getWelcome() ?> <?php echo $this->getAdditionalHtml() ?></p>
Then in the header I added this:
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('welcome')->toHTML(); ?>
That usually works with about anything. But not this time. Nothing. So under the block page/html_header I added this to page.xml:
<block type="core/template" name="header.welcome" as="welcome"/>
This is mt latest attempt. Does anyone have any ideas about how to go about this? I like the welcome message being dynamic.
thanks
The welcome message is just a function of the header block. Lesti_Fpc needs the welcome message in a seperated block. In Magento 1.8 this is solved and the name of the block is welcome. In Magento 1.7 there is a semi-solution in core...
This issue is solved here: (source)
https://gordonlesti.com/lestifpc-magento-1-7-and-the-welcome-message/
I think I have made some progress for this problem. However I am not getting the solution. What I have done is created a new block in the app/design/frontend/default/layout/page.xml file.
I have added this:
<block type="page/html_welcome" name="testwelcome" as="testwelcome"/>
There seems to be a built in core function called "welcome". It can be viewed at app/code/core/Mage/Page/Block/Html/Welcome.php. So That is the reference in the page.xml file.
Then in the header.phtml file in app/design/frontend/default/template/page.html I placed a call for:
<?php echo $this->getChildHtml('testwelcome') ?>
And finally I created a new template file called testwelcome.phtml in app/design/frontend/default/template with the following code:
<p class="welcome-msg"><?php echo $this->getWelcome() ?> <?php echo $this->getAdditionalHtml() ?></p>
I can get the welcome message to display, but I can't seem to get it to render any changes.

Magento - catalog layout

I have modified my magento catalog page using list.phtml by adding manufacturer name next to product name. Now this works well for all categories which have 'Anchor' set as No. It does not show the changes in categories where Anchor is set to yes. Could you please help me on this.
Thanks.
The layout for anchor and non-anchor categories is different look here:
<catalog_category_default>
and
<catalog_category_layered>
in catalog.xml
Perhaps your template only uses the non anchor list.phtml and falls back to base/default for the anchor categories?
In list.phtml I added the manufacturer
<?php echo $_helper->productAttribute($_product, $_product->getAttributeText('manufacturer'),'name') ?> - <?php echo $_helper->productAttribute($_product, $_product->getName() , 'name'); ?></a>

Resources