<?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 ?>
Tag Archives: PHP
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
List Products under a given category
{{block type=”catalog/product_list” category_id=”12″ template=”catalog/product/list.phtml”}}
It will list all the products under the category id “12” .
Site URL in CMS static block / Pages – Magento
{{store url=’mypage.html’}} will return the full sitr ur l . ie http://sitename.com/mypage.html/
and
{{store direct_url=’mypage.html’}} will return the full sitr ur l . ie http://sitename.com/mypage.html
Include a phtml page in CMS block – Magento
The below given code will display the the content added in “newPage.phtml”
{{block type=”core/template” name=”list-categories” template=”catalog/category/newPage.phtml”}}