Get base URL, Media URL, JS URL, Skin URL, Store URL, and Current URL

Basic Questions in magento’s developer mind when start theme development.

  • How to get Base URL in .phtml file.
  • How to get Skin URL in .phtml file.
  • How to display image in CMS page or Static Block.
  • How to get Media URL.
  • How to get JS URL.
  • How to get Store URL.
  • How to get Current URL.

Below are answer available for all above Questions.

Get URL in phtml files.

  1. Get Base Url :

    Mage::getBaseUrl();

  2. Get Skin Url :

    Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN);

    • Unsecure Skin Url :

      $this->getSkinUrl('images/imagename.jpg');

    • Secure Skin Url :

      $this->getSkinUrl('images/imagename.gif', array('_secure'=>true));

  3. Get Media Url :

    Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);

  4. Get Js Url :

    Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS);

  5. Get Store Url :

    Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);

  6. Get Current Url :

    Mage::helper('core/url')->getCurrentUrl();

Get URL in static block or CMS page.

  1. Get Base Url :

    {{store url=""}}

  2. Get Skin Url :

    {{skin url='images/imagename.jpg'}}

  3. Get Media Url :

    {{media url='/imagename.jpg'}}

  4. Get Store Url :

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

Rakesh Patel on sabtwitterRakesh Patel on sabrssRakesh Patel on sabgoogleRakesh Patel on sabgithubRakesh Patel on sabfacebookRakesh Patel on sabemail
Rakesh Patel
Website Devloper at Divine Web Technology
Hello Viewers,
My self Rakesh Patel, And i am website developer from last 6+ Year, I am working as a full time freelancer from last 2years. My skills are Core PHP, Wordpress, Magento, HTML, CSS, Joomla, Drupal, Smarty.

I really like to share my skill to all my developer friends, And also request you all, Please share your skill here so other developer can get help.