Get Magento URL and Path

Home / Magento / Get Magento URL and Path

When you work or develop magento site so many places you need to some magento URL. Magento URL and magento path is very helpful to make development easy. When you want to create magento static block and you want to show some image or set any page link then you need to set exact path for that. Maegnto provide some basic path or URL by default. Here I want to show you magento path and URL.

Use magento URL in static block


{{skin url='images/sampleimage1.png'}}

get Media URL

{{media url='/sampleimage1.png'}}

get Store URL

{{store url='contact.html'}}

get Base URL

{{base url='yourstore/contact.html'}}

Use magento URL path in PHTML

get Homepage URL

<?php $home_url = Mage::helper('core/url')->getHomeUrl(); ?>

Or check current page is homepage

<?php if(
Mage::getSingleton('cms/page')->getIdentifier() == 'home'  &&
Mage::app()->getFrontController()->getRequest()->getRouteName() == 'cms'

not Secure Skin URL

<?php echo $this->getSkinUrl('images/sampleimage.jpg') ?>

secure Skin URL

<?php echo $this->getSkinUrl('images/ sampleimage.gif', array('_secure'=>true)) ?>

get Base URL

<?php Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);?>

get Current URL

<?php $current_url = Mage::helper('core/url')->getCurrentUrl(); ?>

get Magento Media Url

<?php Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);?>

magento Skin Url

<?php Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN);?>

magento Store Url

<?php Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);?>

magento Js Url

<?php Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS);?>

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *