getBaseUrl – Magento URL Path
When developing in Magento and playing arround with Magento Themes there is some functions you should know.
If you want to get the source url of an image, javascript or file, call one of this functions adding your own path at the end.
Under every function there is an example of the output value:
http://example.com/
<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB); ?>
http://example.com/js/
<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS); ?>
http://example.com/index.php/
<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK); ?>
http://example.com/media/
<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA); ?>
http://example.com/skin/
<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN); ?>
Related PostsIf you liked getBaseUrl – Magento URL Path; the posts below might interest you too:
|




December 14, 2011
16:59
Rick, great site and resource.
Wondering if there is a source URL for Magento categories?
Example:
My site is giving certain visitors an SSL Certificate error. Found that not all my links are converting to the secure https link. My host has verified the certificate placement. Your functions above have helped with converting most of my links to https.
Thanks!
December 14, 2011
17:47
Hi Eric,
Thanks !
Try this:
<?php echo Mage::getModel("catalog/category")->load(5)->getUrl() ?>Let me know if it works
March 29, 2012
12:02
Is there any method get the URL link for subsites/subdirectories
like
1) http://mycom.com/store1
2) http://mycom.com/store2
March 29, 2012
12:14
Have you tried to use the method above? I think it’s smart enough to know if you’re in the store1 or store2.
Let me know if it works,
Regards