Merchant Stories

Template Tags: What Magento Store Owners Should Know

Nov 24, 2014 2 min read 610 views
Listen audio
Template Tags: What Magento Store Owners Should Know

In order to configure the necessary block or design special code parts can be used. Magento ®  tags are used in the theme files, blogs, email notifications and on the store pages.

What template tags are

eCommerce templates tag is a part of code enclosed in brackets which contain certain information important for the system to operate. For example: {{domain=””}}. A Template tag can be used for different purposes but they are most necessary in order to:

1. Place links on an online store page without entering a domain name;

2. Install a certain block on a certain store page for the edition of layers and other theme files.

You can use such tags in different blocks on your site pages.

How to use template tags

As an easy example, let’s say you wish to place a banner on your storefront main page indicating that you will be offering holiday discounts up to 60%. You can edit the main page using the following steps. Go to the admin panel then open the home page. The exact path would be CMS – Manage Pages – Home Page.

You will see the home page source code which you can edit as desired. But you should be careful as this is the main page of your site that you edit. If you do not have enough programming skills it would be better to ask the GoMage development team for assistance.

There are two ways to install a banner. First, add the following code to a link to an image created using Photoshop:

<img src="http://www.domain.com/skin/frontend/default/default/images/media/50sale.jpg" 
alt="" />

 

 

Using the template tag you can add the following code:

<img src="{{skin url='images/media/about_us_img.jpg'}}" alt="" />

 

 

It is also very convenient to use the tags responsible for the creation of a static block on your site. E.g. this tag {{block id=’block_id’}} is responsible for a block with a certain identifier. That could be {{block id=’footer_links’}}. You can change static blocks in the admin panel, in CMS > Static Blocks.

There is also a tag {{htmlescapevar=” allowed_tags=”}} that will cancel all layout HTML tags. It is a very useful option if you need to partially edit a page. You can specify the tags that must not be canceled using allowed_tags attribute. List the necessary attributes divided by commas. A working tag looks like this:

{{htmlescapevar='<a href="javascript:alert(1);">Hello</a>'}}

 

 

How do such Magento ® tags work? All links existing on the site will be displayed as simple text but they will not be indexed by search engines.

The tag {{layout handle=”}} can be used to setup HTML layers output. When this option is being configured it is necessary that selected ‘handle’ has the name of a specific layer that is used on the site.

Not a very useful tag, as full media files’ paths are not usually specified in eCommerce, but still widely used one is {{media url=”}}. It helps to output a full path of a specific file in Magento ®.

For example, if you add {{media url=’catalog/product/l/s/dress.jpg’}} you will see this link as a result of a product image http://www.domain.com/media/catalog/product/l/s/dress.jpg.

The tag {{store url=”}} is also very useful. It adds the store URL to the database. Also, this tag will automatically add a slash at the end. It is very important to not leave the URL field blank or you will be redirected to the store home page.

For example:

{{store url='about-magento-demo-store'}}

 

 

The resulting URL will be:

http://www.domain.com/index.php/about-magento-demo-store/

 

 

The tag {{store direct_url=”}} performs the same function but it does not add a slash at the end of the URL.

That's where you contact us!

    By submitting this form you agree to GoMage's Terms of Use and Privacy Policy
    woo-hoo! Now its time to keep checking your inbox, as we will be getting in touch soon. Promise :)
    oops! Thanks. But it seems like some kind of technical issues stop you from meeting GOMAGE. Could you try again?