Magento Mage Core, Admin Static Blocks, or Phtml edits are usually includes getting url path such images, javascript, base url, media and store url. There are different ways to retrieve mentioned URL paths depending on where section you’re editing.
Not secure Skin URL:
Get Magento Media Url
To Retrieve URL path in STATIC BLOCK
To get SKIN URL{{skin url='images/sampleimage.jpg'}}To get Media URL
{{media url='/sampleimage.jpg'}}To get Store URL
{{store url='mypage.html'}}To get Base URL
{{base url='yourstore/mypage.html'}}
TO Retrieve URL path in PHTML
Note: In editing PHTML don't forget to enclode the following code with PHP tagNot secure Skin URL:
<?php echo $this->getSkinUrl('images/sampleimage.jpg') ?>Secure Skin URL
<?php echo $this->getSkinUrl('images/ sampleimage.gif', array('_secure'=>true)) ?>Get Current URL
$current_url = Mage::helper('core/url')->getCurrentUrl();Get Home URL
$home_url = Mage::helper('core/url')->getHomeUrl();Get Magento Media Url
Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
Get Magento Media Url
Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);Get Magento Skin Url
Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN);Get Magento Store Url
Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);Get Magento Js Url
Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS);
20 comments:
Very useful post.thank you
You gave me some good information about the URL path. thanks keep on updating.
I could definitely use this to retrieve url paths. Thanks for this short illustrative guide.
I needed this so badly. Thank you so much. Toggling between all these Magento URLs can be a pain sometimes.
how we can get Skin Url in helper??
You welcome Pete. :)
Good point. I probably make a benchmark on that.
I am really forever saying that its difficult to get good honest help, but here is …
very useful information
thank you guys....
This is what I really needed! Thanks for sharing this info. :-)
Thanks for sharing this Janzell. It's really helpful.
Dude ,
Its not working for {{base url='yourstore/mypage.html'}} ,,
Please let me know how to get base URL ..
I need to change store using CMS-Page.
Please help me out ..
Thanks in advance
Dude,
Sorry for the confusion. Basically, to get the base url, you just need the following
{{base url=''}}
Great resource, I use this as a point of reference when developing Magento sites all the time. Thanks.
Be carefull, tehere is white space in this expresion {{skin url='images/sampleimage.jpg'}} remove it!
Thanks for this useful information... :)
Bookmarked! Thanks!
Thanks for this article. I've bookmarked it because I always forget how to get base url and skin url.
Perfect. Bookmarked, printed, memorized ...
Bookmarked and used everyday !!
Thanks!
RiseCommerce.Com
Post a Comment