How to add Logout URL under every section of My Account Page? - magento

I have a requirement that the logout url must be visible only in My Account bottom for every section of it like on "Account Information","Address Book", "My Orders" similar for all.
How to do this?
Where should I write
action method="addLink" translate="label title" module="customer"><label>Log Out</label><url helper="customer/getLogoutUrl"/><title>Log Out</title><prepare/><urlParams/><position>100</position></action>
in My customer.xml file.

You can remove the block 'customer_logged_in' in customer.xml and then you can add/make a block in customer.xml like this.
<reference name="content">
<block type="page/html_wrapper" name="my.account.wrapper" translate="label">
<label>My Account Wrapper</label>
<action method="setElementClass"><value>my-account</value></action>
<block type="core/template" name="logout_link" template="customer/logout_link.phtml"/>
</block>
</reference>
And the content of the logout_link.phtml would be something like,
<?php
$loggedIn = $this->helper("customer")->isLoggedIn();
if($loggedIn == 1){
echo "<a href=\"".Mage::getBaseUrl()."customer/account/logout/\" >LOGOUT</a>";
}else{
echo "<a href=\"".Mage::getBaseUrl()."customer/account/\" >LOGIN</a>";
}?>
....

It's better to use these URL's:
Mage::helper('customer')->getLogoutUrl()
Mage::helper('customer')->getLoginUrl()
It uses the customer helper instead of a hard coded URL.

Related

How to call mini cart in footer in magento?

I want to call mini cart in footer.
i have to use below code in xml file
<reference name="footer">
<block type="checkout/cart_sidebar" name="footer_cart" template="checkout/cart/topcart.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>
</reference>
or <?php echo $this->getChildHtml('top_cart') ?> in footer.phtml.
but its not working for me. please give me any idea for do it.
you name of block is footer_cart so
change
<?php echo $this->getChildHtml('top_cart') ?>
to
<?php echo $this->getChildHtml('footer_cart') ?>
other problem is you are calling the wrong file
change
<block type="checkout/cart_sidebar" name="footer_cart" template="checkout/cart/topcart.phtml" before="-">
to
<block type="checkout/cart_sidebar" name="footer_cart" template="checkout/cart/sidebar.phtml" before="-">

Add Banner Below Menu in Category Page

I need to add the category banner below the Breadcrumbs.
I have tried by adding new reference
<?php echo $this->getChildHtml('category_banner') ?>
in the 2columns-left.phtml
and in local.xml
<catalog_category_view>
<reference name="category_banner">
<block type="core/template" name="topbanner" template="catalog/category/category-image.phtml" before="-"></block>
</reference>
</catalog_category_view>
<catalog_category_default translate="label">
<reference name="category_banner">
<block type="core/template" name="banner" template="catalog/category/category-image.phtml"></block>
</reference>
</catalog_category_default>
But output is not coming.
Added new line inside the all layout i.e 2columns-left.phtml etc.
<?php echo $this->getChildHtml('category_banner') ?>
added below line inside your xml
<catalog_category_view>
<reference name="root">
<block type="core/template" name="category_banner" template="catalog/category/category-image.phtml" before="-"></block>
</reference>
</catalog_category_view>

Magento getChildHtml block not rendering

I'm attempting to rearrange some elements on a webpage and my code won't render it its new position.
The top of the page is handled in view.phtml and the bottom in list.phtml. I'm wanting to move form.phtml from view to list.
The xml looks like this:
<block type="review/product_view" name="product.info" template="catalog/product/view.phtml">
<block type="catalog/product_view_media" name="product.info.media" as="media" template="catalog/product/view/media.phtml">
<action method="disableGallery"/>
</block>
<block type="review/form" name="product.review.form" as="review_form" template="review/form.phtml"/>
the view.phtml contains this call:
<?php echo $this->getChildHtml('review_form') ?>
However, no dice. I'm very new to Magento, so any help would be great. I've looked into the following questions and more with no results:
Nested block within a reference not rendering when using ->getChildHtml()
Magento $this->getChildHtml('media') return blank
Call magento template via $this->getChildHtml()
Thanks!
As per as your description,review child block is call in under view then...
it should be
<block type="review/product_view" name="product.info" template="catalog/product/view.phtml">
<block type="catalog/product_view_media" name="product.info.media" as="media" template="catalog/product/view/media.phtml">
<action method="disableGallery"/>
</block>
<block type="review/form" name="product.review.form" as="review_form">
<block type="page/html_wrapper" name="product.review.form.fields.before" as="form_fields_before" translate="label">
<label>Review Form Fields Before</label>
<action method="setMayBeInvisible"><value>1</value></action>
</block>
</block>
.........

Reordering a productlist block in Magento

I'm a bit of a Magento noob. I have the following code in the Page Layout section of my home page:
<reference name="content">
<block type="catalog/product_list" name="featured" template="catalog/product/list.phtml">
<action method="setCategoryId"><category_id>8</category_id></action>
</block>
</reference>
How do I change what attribute the products in this block are ordered by?
The order of a product list is generally controlled by the toolbar block Mage_Catalog_Block_Product_List_Toolbar. But if you want to be able to influence the way the product collection is ordered from the layout, you can do the following:
Rewrite the block Mage_Catalog_Block_Product_List and add a function to it:
public function setOrder($attribute, $direction)
{
$collection = $this->_getProductCollection();
$collection->clear()->setOrder($attribute, $direction);
$this->_productCollection = $collection;
}
in the layout update add an action node, e.g.
<reference name="content">
<block type="catalog/product_list" name="featured" template="catalog/product/list.phtml">
<action method="setCategoryId"><category_id>8</category_id></action>
<action method="setOrder"><attribute>name</attribute><direction>desc</direction></action>
</block>

products per row in grid view magento go

I am using magento go.
I have created a category and assign 8produts to it, i want to display 4 products in each row but it show 5-products.
Please give me solution.
Thanks
put this code in your category which you want to diplay 4 products, just open your category from admin and open custom design tab and put below code in custom layout update field.
<reference name="product_list">
<action method="setColumnCount"><columns>4</columns></action>
</reference>
Hope this will help you
Go to this path: magento_folder/app/design/frontend/mytheme(your_package)/neo(your_theme)/layout/catalog.xmlWrite this : <action method="setColumnCount"><count>4</count></action>
<catalog_category_default translate="label">
<reference name="content">
<block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml">
<action method="setColumnCount"><count>4</count></action>
" "
" "
" "
</block>
And after that in the same catalog.xml file below add the same code (under :<catalog_category_layered translate="label"> tag) like this :
<catalog_category_layered translate="label">
<reference name="content">
<block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml">
<action method="setColumnCount"><count>4</count></action>
" "
" "
" "
</block>
Hope this may help you

Resources