Adding Cart to top.menu in Magento - magento

I'm building a navigation bar that includes the user menu and cart along with the wishlist but trying to figure out how one would add it in the xml mockup to include it using the getChildHtml function.
XML file: page.xml
<block type="page/html_header" name="header" as="header">
I have
<block type="core/text_list" name="top.menu" as="topMenu" translate="label">
Now as far as I can see I have to include the following somewhere or extend the block or something not really sure, please help me in the right direction or even point me to a developers guide that would cover this.
<block type="checkout/cart_sidebar" name="cart_sidebar" as="topcart" template="checkout/cart/sidebar.phtml"/>

Create a file local.xml in your theme folder app/design/frontend/your_package/your_theme/layout/
add the following lines and save the file.
<layout version="0.1.0">
<default>
<reference name="top.menu">
<block type="checkout/cart_sidebar" name="cart_sidebar" as="topcart" template="checkout/cart/sidebar.phtml"/>
</reference>
</default></layout>
Don't forget to clear magento cache(System->Cache management) after applying the change.
In order to learn more about Magento blocks ,layouts ,templates there is an official magento guide check it here

Related

How to remove recently viewed products in product page magento

I want to remove the recently viewed products which are in the product page . and i have tried many times but not been able to find a solution . i have done some editing in the local.xml
but it didnot worked
Open reports.xml of your theme template. (app\design\frontend\theme\default\layout\reports.xml)
There will be code like
<block type="reports/product_viewed" before="right.permanent.callout" name="right.reports.product.viewed" template="reports/product_viewed.phtml" />
Remove that, clear cache and Reload
Try removing the related products block from <catalog_product_view> in your catalog.xml file:
<reference name="right">
<block type="catalog/product_list_related" name="catalog.product.related" before="-" template="catalog/product/list/related.phtml"/>
</reference>
Remove the block:
<block type="catalog/product_list_related" name="catalog.product.related" before="-" template="catalog/product/list/related.phtml"/>
Try and find the viewed products instruction in your store. And then, in yout theme's local.xml, use the correct handle to remove it from the wanted section.
For example, how to remove Magento's base theme default instruction in product view:
<catalog_product_view>
<remove name="right.reports.product.viewed" />
</catalog_product_view>
The next example is how I removed it from my store, which was based on a different theme:
<catalog_product_view>
<remove name="product.info.viewed" />
<catalog_product_view>
Clear the cache and you're good to go!
This is the recommended way. You should avoid to duplicate or modify the original XML layout files. Always use your theme local.xml file instead.

magento change block not working properly

I am using magento 1.7
on my product page I have added related product on right sidebar.
there are other block also displayed on sidebar these are
-related product
-recently viewed product
-mycart
-paypal logo
Now I want related product to get displayed after mycart and paypal logo, right now it is displayed on top of right bar
I have used before and after but that is not working.
These is my code
paypal.xml
<reference name="right">
<block type="paypal/logo" name="paypal.partner.right.logo" after="cart_sidebar" template="paypal/partner/logo.phtml"/>
</reference>
catalog.xml
<reference name="right">
<block type="catalog/product_list_related" name="catalog.product.related" after="paypal.partner.right.logo" template="catalog/product/list/related.phtml"/>
</reference>
checkout.xml
<reference name="right">
<block type="checkout/cart_sidebar" name="cart_sidebar" template="checkout/cart/sidebar.phtml" before="-">
<action method="addItemRender"><type>simple</type><block>checkout/cart_item_renderer</block><template>checkout/cart/sidebar/default.phtml</template></action>
<action method="addItemRender"><type>grouped</type><block>checkout/cart_item_renderer_grouped</block><template>checkout/cart/sidebar/default.phtml</template></action>
<action method="addItemRender"><type>configurable</type><block>checkout/cart_item_renderer_configurable</block><template>checkout/cart/sidebar/default.phtml</template></action>
<block type="core/text_list" name="cart_sidebar.extra_actions" as="extra_actions" translate="label" module="checkout">
<label>Shopping Cart Sidebar Extra Actions</label>
</block>
</block>
how can I put mycart and paypal logo on top of right bar.
First you need to create or update your local.xml file IF you do not have a local.xml file you can create one in
app->frontend->[Package Name]->[Theme Name]->layout->local.xml
Once this is created you can copy exactly what I have in this post into that file for a start of how to use one.
DO ALL UPDATES THROUGH A LOCAL.XML file not through catalog.xml or checkout.xml !! This will make upgrades significantly easier later down the road. Additionally, you will be able to quickly see all changes you have made to your site in one file. This way I can see what you are actually updating.
<?xml version="1.0" encoding="UTF-8"?>
<layout>
<default>
<reference name="right">
<!-- <action method="unsetChild"><alias>catalog.product.related</alias></action> -->
<block type="catalog/product_list_related" name="catalog.product.related" after="-" template="catalog/product/list/related.phtml"/>
</reference>
</default>
</layout>
If you end up with two try uncommenting my action method.. I can't remember if you have to declare it in separate reference or within there because I didn't test this but give it a try

how to find the links in the footer in magento

I am trying to find the links in the footer of a magento website , but i am having difficulty finding the phtml file. I found the block code in the page.xml file
<block type="page/template_links" name="footer_links" as="footer_links" after="footer.newsletter" template="page/template/links.phtml"/>
but i cannot find the file links.phtml file , i checked the current template
website/app/design/frontend/website.com/default/template/page/
but i cannot see any template folder there.
Can anybody help me please with this, how to find the file, i even tried turning on template path hints it didn't help. Thanking you for your help in advance.
It can be confusing, the footer links i Magento are generated in one of two ways:
1) Added via XML layouts, which is how the sitemap link etc are added, example:
contacts.xml
<reference name="footer_links">
<action method="addLink" translate="label title" module="contacts" ifconfig="contacts/contacts/enabled">
<label>Contact Us</label>
<url>contacts</url>
<title>Contact Us</title>
<prepare>true</prepare></action>
</reference>
You can add more like this, or comment out to remove each link
They are generated using a standard template file (template/page/template/links.phtml) which is enabled in the config below. Each link definition as above (there's multiple in different xml configs) will use the template below to display the actual HTML link.
page.xml
<block type="page/html_footer" name="footer" as="footer" template="page/html/footer.phtml">
<!-- uncomment this to ditech them.. -->
<block type="page/template_links"
name="footer_links" as="footer_links"
template="page/template/links.phtml" />
</block>
2) You will find a static block called footer_links which also includes some links, this is to make it easier for you to add your own link. They are enabled inside
cms.xml
<reference name="footer">
<block type="cms/block" name="cms_footer_links" before="footer_links">
<!--
The content of this block is taken from the database by its block_id.
You can manage it in admin CMS -> Static Blocks
-->
<action method="setBlockId"><block_id>footer_links</block_id></action>
</block>
</reference>
Both methods are used to generate the footer links which can be confusing :)
Try this path:
/app/design/frontend/base/default/template/page/template
Hope that helps you...
to remove "orders and returns" from the footer link i had to comment out the block from sales.xml file
<!-- <default>
<reference name = "footer_links">
<block type="sales/guest_links" name="return_link"/>
<action method="addlinkBlock">
<blockName>return_link</blockName>
</action>
</reference>
</default>
-->

Adding image in Magento via update layout

I'm trying to figure out how to add images, etc. to the left sidebar portion of a 2 column with left sidebar page in Magento using the layout update in the cms ->page->design portion of the admin area.
Is it possible to do this from the update layout xml area? If not, could you explain how to create a module (or whatever else would be required).
Thanks.
If you look in base/default/layout/catalog.xml, you will see an example of using a template with an image placeholder that can be specified in your Update Layout XML area:
<reference name="left">
<block type="core/template" name="left.permanent.callout" template="callouts/left_col.phtml">
<action method="setImgSrc"><src>images/media/col_left_callout.jpg</src></action>
<action method="setImgAlt" translate="alt" module="catalog"><alt>Our customer service is available 24/7. Call us at (555) 555-0123.</alt></action>
<action method="setLinkUrl"><url>checkout/cart</url></action>
</block>
</reference>
So, in your Update Layout XML, you would write something like:
<reference name="left.permanent.callout"> <!-- match this to the block name from above -->
<action method="setImgSrc"><src>images/media/my_file_name.jpg</src></action>
<action method="setImgAlt" translate="alt" module="catalog"><alt>Some text here</alt></action>
<action method="setLinkUrl"><url>your/path</url></action>
</reference>
You can adapt that by taking a copy of the template file left_col.phtml and making changes as you wish.

Magento local.xml layout file - overriding <remove name="left"/>

Is there any way to override, or re-add something that was removed via it's xml layout, using local.xml?
I've made a theme that's all based on one page layout, 2columns-left. But a lot of pages, such as the sitemap, are set to use a 1column layout. So for example, in catalog.xml, we have:
<catalog_seo_sitemap translate="label">
<label>Catalog Seo Sitemap (Common)</label>
<remove name="right"/>
<remove name="left"/>
<reference name="root">
<action method="setTemplate"><template>page/1column.phtml</template></action>
</reference>
<reference name="content">
<block type="page/template_container" name="seo.sitemap.container" template="catalog/seo/sitemap/container.phtml">
<block type="page/template_links" name="seo.sitemap.links" as="links" template="page/template/links.phtml"/>
<block type="page/html_pager" name="seo.sitemap.pager.top" as="pager_top" template="page/html/pager.phtml"/>
<block type="page/html_pager" name="seo.sitemap.pager.bottom" as="pager_bottom" template="page/html/pager.phtml"/>
</block>
</reference>
</catalog_seo_sitemap>
And in my local.xml, I can override the root template to use by adding:
<catalog_seo_sitemap>
<reference name="root">
<action method="setTemplate"><template>page/2columns-left.phtml</template></action>
</reference>
</catalog_seo_sitemap>
So it's now showing the sitemap in a 2column left layout. But there's nothing in the left column, as the < remove name="left" /> has removed it. I hate that I have to override this whole catalog.xml just to remove that, as it's a pain then when they update to a new version, I need to update all these extra layout files too.
So, is there any way to fix that using my local.xml? I think for the default Magento themes, they should have everything set to use the 3column layout, as that way you're free to remove whatever you don't need, but it's all there by default, so all changes can be done in the local.xml file.
Out of the box there's no way to unremove a layout block that's been removed by a previous call to <remove />. '
However, there's enough eventing in the Layout system that you can implement this yourself. And by "yourself", I mean I've created an experimental extension that adds a <unremove /> tag to the XML Layout system's grammer.
This has been asked before but no conclusion was reached. You can create a replacement block in your local.xml but there is no guarantee the child blocks added to it will be done so after your local changes.
<catalog_seo_sitemap>
<reference name="root">
<action method="setTemplate"><template>page/2columns-left.phtml</template></action>
<block type="core/text_list" name="left" as="left" translate="label">
<label>Left Column</label>
</block> <!-- Copied from page.xml -->
<block type="core/text_list" name="right" as="right" translate="label">
<label>Right Column</label>
</block> <!-- Copied from page.xml -->
</reference>
</catalog_seo_sitemap>
I've managed to do this by just changing the blocks name when reading it. Seems that if you remove a block and re-add it with the same name the remove label will apply to all blocks of the same name. In my case it was removing a account navigation and adding to the header.
<remove name="customer_account_navigation" />
<block type="customer/account_navigation" name="customer_account_nav" as="accountNavigation" template="customer/account/navigation.phtml">

Resources