Getting the Magento Base Paths and URL’s

Just a little reference:

 Mage::getBaseDir(‘app’) => Get app directory path
 Mage::getBaseDir(‘media’) => Get media directory path
 Mage::getBaseDir(‘design’) => Get design directory path
 Mage::getBaseDir(‘code’) => Gives code directory file path
 Mage::getBaseDir(‘lib’) => Gives lib directory file path
 Mage::getBaseDir(‘skin’) => Gives skin directory file path
 Mage::getBaseDir(‘var’) => Gives var directory file path
 Mage::getBaseDir(‘cache’) => Gives cache directory file path
 Mage::getBaseDir(‘log’) => Gives log directory file path

Urls:

 Mage::getBaseUrl() => Get base url path e.g. http://yourwebsite.com/
 Mage::getBaseUrl('media') => Get MEDIA folder path e.g. http://yourwebsite.com/media/
 Mage::getBaseUrl('js') => Get JS folder path e.g. http://yourwebsite.com/js/
 Mage::getBaseUrl('skin') => Get SKIN folder path e.g. http://yourwebsite.com/skin/
 
 Mage::getUrl('',array('_secure'=>true))
 Mage::getUrl('module/controller/action',array('_secure'=>true))
 Mage::getUrl('module/controller/action')

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

Static Blocks

{{base url=''}}
{{skin url='images/skinimage.jpg'}}
{{media url='/mediaimage.jpg'}}
{{store url=''}}

Finding overridden templates in Magento

Magento is pretty damned cool! I’m still getting used to it and so here’s another hint for you!

Anyway, the way the templating system is structured means that you can create a new folder and override the defaults by recreating the class/view/whatever in that folder.

For instance, our default customer login template resides in

/app/design/frontend/THEMENAME/template/customer/account/login.phtml

This template can be overridden with another module, and it will automatically use the THEMENAME in question, so you can have multiple versions of the same view.

This is where it gets confusing!

For instance, I was happily editing said login page, only to discover that nothing had changed! I was on the wrong template! Anyway, it turns out that if you log into the admin panel, you can click on the System > Configuration menu.

Once there, at the top left, there is a dropdown select menu called ‘current configuration scope. Select the theme you are working on, and the page will reload. (This is based on the Manage stores section of the admin panel, which I havent worked on yet, but the essence of it is that you have a base system, which can have multiple stores, which can have multiple views.)

Once the page reloads, scroll down to the bottom of the left-hand column, and look for ‘Developer’ in the advanced menu. In the ‘Debug’ panel, you can turn Template Path Hints on or off. Hit save, and you’re almost set to go. Lastly we need to clear the cache, so click on the System menu, and select Cache Management. I leave cache OFF in my dev environment, however you can click select all, and click refresh option in the dropdown next to submit (should alreday be selected), then submit.

OK, so what did all that do then? Well, if you refresh the page you are working on, you’ll notice it suddenly looks messy! However, you can see exactly where each part of the page came from! 😀 When you are working on a project of the kind of size I’m working on right now (i.e. huge) then there’s a lot of time to be saved!

Template Path Hints turned ON
Template Path Hints

Setting the PATH environment variable for your executables on Mac OS X

Sure, you can cd /wherever/your/program/lies, then run ./program_name, but thats lame!

I just installed PEAR and PECL in work, and it went int /usr/local/pear. Pear itself was in /usr/local/pear/bin, so thats the path we need to add.

From your terminal:

cd ~
nano .profile

Once Nano opens (or vi, emacs, whatever you like using as your command line text editor), add the following, and thats it!

export PATH=/path/to/your/bin:/maybe/more/folders:/one/more/for/good/measure:$PATH

As you can see, you can add several paths in the one line, just separate them by a :

Remember to quit and reload your terminal!