kingberrill
4/5/2016 - 6:10 PM

Get Magento URL's in PHP & CMS

Get Magento URL's in PHP & CMS

<h2>Magento PHP Url's</h2>
<?php
// get base url
Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
// get store url
Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
// get route name
Mage::app()->getFrontController()->getRequest()->getRouteName();
// get url identifier
Mage::getSingleton('cms/page')->getIdentifier();
// Get full url
Mage::getUrl() . Mage::getSingleton('cms/page')->getIdentifier();
// Get Current Url
$currentUrl = Mage::helper('core/url')->getCurrentUrl();
$url = Mage::getSingleton('core/url')->parseUrl($currentUrl);
$path = $url->getPath();
// get home url
$home_url = Mage::helper('core/url')->getHomeUrl();
// get media url
Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
// get js url
Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS);
// get skin url
Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN);
// get unsecure url
$this->getSkinUrl('images/sampleimage.jpg');
// get skin secure url for file
echo $this->getSkinUrl('images/ sampleimage.gif', array('_secure'=>true));
?>
<h2>Magento CMS Urls</h2>
<!--get base url-->
{{base url='yourstore/contact.html'}}
<!--get store url-->
{{store direct_url="page.html"}}
<!--get js url-->
{{secure_base_url}}js/
<!--get media url-->
{{media url='/sampleimage1.png'}}
<!--get skin url-->
{{skin url='images/sampleimage1.png'}}