<?php
if ($this->helper('customer')->isLoggedIn() ){
echo '<a href="<?php echo $this->getUrl('customer/account/login/');?>">Login</a>';
}else {
echo '<a href="<?php echo $this->getUrl('customer/account/logout/');?>">Logout</a>';
}
?>
All posts by Pramod T P
How to get the logged in user details on phtml page – Magento
<?php
$customer = Mage::getSingleton('customer/session')->getCustomer();
$email = $customer->getEmail();// for email address
$firstname = $customer->getFirstname();// For first name
$lastnam e= $customer->getLastname();// For last name
?>
Scrollers – Javascript
Follow the below given link
Strip HTML tags except the given – PHP
<?php $text = '<p>TestP</p><b>Tesb</b> <a href="">TestA</a>'; echo strip_tags($text); //Strip all tags echo strip_tags($text, '<p><a>'); //Strip all tags except p and a ?>
How to get the current page url – Magento
<?php
$currentUrl = $this->helper('core/url')->getCurrentUrl();
// Displays URL of the current page
?>
List category and subcategory on sidebar – Magento
<?php
$obj = new Mage_Catalog_Block_Navigation();
$store_cats = $obj->getStoreCategories();
$current_cat = $obj->getCurrentCategory();
$current_cat = (is_object($current_cat) ? $current_cat->getName() : '');?>
<?php foreach ($store_cats as $cat)
{ if ($cat->getName() == $current_cat) {
echo '<li style="padding-left:5px;">
<a href="'.$this->getCategoryUrl($cat).'">'.$cat->getName()."
</a>n<ul>n";
foreach ($obj->getCurrentChildCategories() as $subcat)
{ echo '<li style="padding-left:15px;">
<a href="'.$this->getCategoryUrl($subcat).'">'.$subcat->getName()."</a>
</li>n"; }
echo "</ul>n</li>n"; }
else
{ echo '<li><a href="'.$this->getCategoryUrl($cat).'">'.$cat->getName()."
</a></li>n"; }}
?>
How to remove the Estimate Shipping and Tax box – Magento
Remove the following code from /app/design/frontend/your_package/yourtheme/layout/checkout.xml
<block type=”checkout/cart_shipping” name=”checkout.cart.shipping” as=”shipping” template=”checkout/cart/shipping.phtml”/>
How to remove the discount / coupon code from cart page – Magento
Remove the following code from /app/design/frontend/your_package/yourtheme/layout/checkout.xml
<block type=”checkout/cart_coupon” name=”checkout.cart.coupon” as=”coupon” template=”checkout/cart/coupon.phtml”/>
Product description on product listing page – Magento
<?php echo $_product->getShortDescription(); // for printing short description echo $_product->getDescription(); // for printing description //For displaying description, Go to the admin pannel //Catalod->Attributes-> Manage Attributes and edit the description attribute. //Set "Used in product listing" to "Yes". ?>
Include a block in sidebar – Magento
<reference name="left">
<block type="catalog/navigation" name="catalog.leftnav" template="catalog/navigation/left_nav.phtml" />
</reference>
Please create file with the given name "left_nav.phtml " and put it in the corresponding location
eg : /app/design/frontend/your_package/yourtheme/template/catalog/navigation/left_nav.phtml