Include a Javascript file into Magento templates

Customising your magento store can be a good way to set your store apart from the competition so adding features that require javascript files is a common task when building a project.  Learn how to include a javscript file into your magento page templates with this quick how to.The default layout template load is made primarily through the page.xml file located at the following url for custom themed installs /app/design/frontend/your-instance-name/your-theme-name/layout/page.xml , or for the default theme at /app/design/frontend/default/default/layout/page.xml.

Find the following block encapsulator <block type=”page/html_head” name=”head” as=”head”> and simply add the following command inside the block

<action method=”addJs”><script>yourscriptname.js</script></action>

Then upload you updated page.xml file.

With that done, you need to now upload your javascript file to /skin/frontend/your-instance-name/your-theme-name/js/yourscriptname.js, or for the default theme /skin/frontend/default/default/js/yourscriptname.js

Get the current category name in Magento

A key part of the request execution has information stored into the Mage registry and accessing this information is a simple call requesting the needed data.  Learn how to access the registry to find the current category title.

The registry object we are interested in is ‘current_category’ and we will utilise the registry call getName() to create call to retrieve the needed information thusly;

Mage::registry('current_category')->getName();

src: http://www.magento-tutorial.com/