<?php
Mage::getSingleton('core/session', array('name' => 'adminhtml'));
$session = Mage::getSingleton('admin/session');
if ( $session->isLoggedIn() ){
echo "Admin is logged in";
}
?>
Monthly Archives: March 2011
Downgrade PHP from 5.3 to 5.2 – PHP
http://ubuntuforums.org/archive/index.php/t-1459163.html
How to check if an user is logged in – Magento
<?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>';
}
?>
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”/>