Magento - Adding to the Layout - magento

I have this section in one of my layout files:
<blog_post_view>
<reference name="content">
<block type="blog/post" name="post" template="aw_blog/post.phtml" />
<block type="socialbookmarking/bookmarks" name="bookmarks" template="bookmarks/bookmarks.phtml"/>
</reference>
</blog_post_view>
This first block shows a post and the second block shows some social bookmarking icons. The problem is the section which displays the post also displays the 'add comments' section. I want to add the social icons between the post and the comments.
How can I do this? Ie. add the Social block in the middle of the Post block?
Thanks!

Change it to:
<blog_post_view>
<reference name="content">
<block type="blog/post" name="post" template="aw_blog/post.phtml">
<block type="socialbookmarking/bookmarks" name="bookmarks" template="bookmarks/bookmarks.phtml"/>
</block>
</reference>
</blog_post_view>
and then inside the post template (aw_blog/post.phtml) put the following where you want the bookmark-things to appear:
<?php echo $this->getChildHtml('bookmarks'); ?>

Related

Put a banner on top of two column cms page in magento

I created a new CMS with 2column layout and now want to put full width or 1 column banner on top of 2 columns.
I tried
<reference name="root">
<block type="cms/block" name="my_banner" as="my_banner" template="path/to/my_banner.phtml" />
</reference>
in Layout Update XML but nothing happened. Any help will be appreciated!
As per #richtea response I updated the CMS page layout settings like the screenshot given below but didn't worked
http://screencast.com/t/CiidoSRgkNs
You are requesting the page to add a CMS block, but referencing a PHTML template. You can either:
Insert a CMS block, use the below and create a block in your admin panel with identifier my_banner.
<reference name="root">
<block type="cms/block" name="my_banner">
<action method="setBlockId"><block_id>my_banner</block_id></action>
</block>
</reference>
Or insert a template file as follows
<reference name="root">
<block type="core/template" name="my_banner" as="my_banner" template="path/to/my_banner.phtml" />
</reference>

get error messages in content area on cart page Magento

HI i have made a module in which i have a controller which adds product to the cart through url . I have add a error messages from controller if the product is not valid.
The problem is the error message is shown above the content area .I need to show those in the content area.I have also tried to add these blocks in
checkout.xml in content area
<reference name="content">
<block type="checkout/cart" name="checkout.cart">
<block type="core/messages" name="global_messages" as="global_messages"/>
<block type="core/messages" name="messages" as="messages"/>
but still it not loads the messages in the content area and show above the content area. Can you please suggest me how can i do this.
What are you using to generate these errors - default magento handlers? they generate errors just above the breadcrumb area.
One option would be to give it a id/class and manipulate through javascript.
OR,
Generate custom errors.
You can either unset/re-add blocks as needed with the following methods:
<action method="unsetChild"><name>global_notices</name></action>
<action method="unsetChild"><name>global_messages</name></action>
<action method="unsetChild"><name>messages</name></action>
<block type="page/html_notices" name="global_notices" as="global_notices" template="page/html/notices.phtml" />
<block type="core/messages" name="global_messages" as="global_messages"/>
<block type="core/messages" name="messages" as="messages"/>
If adding these as needed using template hints to confirm does not work, find the following line in
app\design\frontend\base\default\template\checkout\cart.phtml
<?php echo $this->getMessagesBlock()->toHtml() ?>
And comment it out/move it to where you wish to render it.

how to insert my custom template file in list page using xml without using getChild html and not rewrite list.phtml

This is how i tried. bud didn't get answer. what my template will do is each product image will have a like button. i have done with view.phtml but not in list.phtml. Pls friends broadcast your knowledge.
<reference name="content">
<block type="productlike/most" name="productlike" before="-">
<action method="setTemplate" ifconfig="section_1/group_1/enabled"><template>productlike/like.phtml</template>
</action>
</block>
</reference>

how to display recently viewed products list on product details page - magento

I have used mobileshoppe theme for magento and trying to display recently viewed product list at product details page but some how its not working...
Added code below at catalog.xml
<catalog_product_view translate="label">
<reference name="content">
<block type="reports/product_viewed" name="product.recently.viewed" as="product_recently_viewed" template="reports/product_viewed.phtml"/>
</reference>
</catalog_product_view>
and below code at app\design\frontend\default\mobileshoppe\template\catalog\product\ view.phtml
<?php echo $this->getChildHtml('product_recently_viewed') ?>
I have tried the same with default theme and its also not working, can any one help me to figure out this issue ?
Thanks...
On the the product detail template (view.phtml) you have to be more specific in the xml where you want to place the block. See the example below using local.xml in the theme layout directory (app/design/frontend/your package/your theme/layout/local.xml) to insert the block. Here's an example from a site I'm working on. Ironically we are having problems with it displaying consistently, which I'm trying to figure out right now, but this is working most of the time! Try getting more specific in your catalog.xml and it should work. The xml is in local.xml, the echo is in catalog/product/view.phtml
<?php echo $this->getChildHtml('recently_viewed') ?>
<catalog_product_view>
<reference name="content">
<reference name="product.info">
<block type="reports/product_viewed" name="left.reports.product.viewed" template="reports/product_viewed.phtml" as="recently_viewed" />
</reference>
</reference>
Can you please replace xml reference content to left.
Instead of this
<reference name="content">
Use below and check
<reference name="left">
As it is a part of sidebar so it should work with left / right column as you want to display in page.
Cheers!

Magento Block Placement

I want to add the block section below on the product detail section
currently its above
as shown in below image
does any one knows this?
my layout is
1st for facebook comment
<reference name="product.info">
<block type="facebookcomments/catalog_product_comments" name="product.info.facebookcomments" template="facebookcomments/catalog/product/comments.phtml"/>
2nd is for facebook like
<reference name="product.info">
<block type="facebookilike/catalog_product_facebookilike" name="product.info.facebookilike" template="facebookilike/catalog/product/facebookilike.phtml"/>
still not getting this
In catalog_product_view handle of your theme/module layout:
(note i'm pseudo-coding based on the debug block names in your screenshot. I may not have the correct block/template/handles, but you get the idea)
<reference name="content">
<block type="mageplace_facebook/like_catalog_product_facebooklike"
after="product.info"
name="facebook.like.block.name"
template="path/to/facebooklike/template.phtml" />
</reference>
Check the layout xml of the Facebook Comments module, as it's obviously in the right place.

Resources