rss
twitter
    Find out what I'm doing, Follow Me :)

Wednesday, December 30, 2009

Pin It

Widgets

Magento – url functions

Magento had some very handy functions that easily allow you to find some fundamental urls of your site from your phtml files so you can avoid hardcoding them. These are:

    $this->getBaseUrl() - returns the base url of your store (funnily enough)
   
    $this->getSkinUrl() - returns the url of the folder containing your css, images and local js files (eg skin/frontend/default/your_theme, will vary depending on what package and theme the page is using).
    
    So to find the image logo.gif in the images folder you would call
   
    $this->getSkinUrl(’images/logo.gif’);

    It should be noted that if getSkinUrl does not find the file that you have specified (like images/logo.gif) then it will default to looking in the default theme folders rather than your custom theme folders.

   $this->getJsUrl() - returns the url of the main js folder. So if you want to include a new js library from a template you can use this.

Source : http://loonyblurb.net/

No comments:

Post a Comment