You may be familiar with some of the template directives you can use in the Magento CMS pages and blocks. Their syntax is distinguished by the double curly braces that enclose the directives.
Today, we’ll have a quick look at the store directive used to generate store URLs and the parameters you can pass to it.
You’ve probably seen the most common one:
<a href="{{store url=""}}">Go to home page</a>
But you may not be aware of the different parameters you can pass to the store directive when creating store URLs.
The parameters of interest are:
- url
- direct_url
- _query
- _query_[name]
Let’s have a look at each of those.
1. url
The url paramter generates a URL using the Magento routing. This means it will take anything you pass to the store url directive append it to the store base URL and append a ‘/’. So for example, you can create a URL to the contact us page like so:
<a href="{{store url="contacts"}}">Contact Us</a>
Resulting in a URL like http://yourstore.com/contacts/.
2. direct_url
If you need to create a URL to a category or product, you can use the direct_url parameter. In that case, whatever you pass to the store directive will simply be appended to the base URL. For example, if your settings are that .html is added to your links, a link to a category can be created like so:
<a href="{{store direct_url="category/subcategory.html"}}">Our Latest Range</a>
3. _query and 4. _query_[name]
If you need to generate URLs with query parameters, there are two ways Using the _query parameter, you can add an arbitrary query string to the URL like so:
<a href="{{store direct_url="category/subcategory.html" _query="a=param_a&b=param_b"}}">Our Latest Range</a>
Or you can use the second parameter syntax where you define the query parameter name with the parameter itself:
<a href="{{store direct_url="category/subcategory.html" _query_a="param_a" _query_b="param_b"}}">Our Latest Range</a>
This results in the same URL as the previous example:
http://yourstore.com/category/subcategory.html?a=param_a&b=param_b
Originally published on magebase.com. Copyright © 2010 Magebase - All Rights Reserved.




Proud members of the
Very Cool! Thank you!
The query parameters are very helpful.
Hi Robert,
Did this work for you us when used with the fck editor? ie. when this link to the description or the short description it comes out : http:www.domain.com/{{store url=
Any ideas how to over come this?
(using mag 1.4.1.1)
Thanks!
You probably need to enter the {{… }} by switching to plain mode and not use the wysiwyg mode. Also save while in plain mode. Otherwise the wysiwyg may interfere.
Btw, in which area are you trying to use this?
I did use it with the plain mode, also the saving with it (tried it before posting here for help).
I’m using it in the description section of the product page (“Description” and “Shore Description”).
Here is the code: contact us
Here is the result on front-end: http://domain/category/{{store url=
Two more things that i saw when using it in the product description are:
1. It ads the category to the link
2. if there is another link using this method after the first one, it is showing the html: <a href="store etc…
Any thoughts?
Robert,
Did you by any chance reproduces this bug? I’m trying to do it in the product page (catalog->managed products->selected product->description
Thanks,
Sharon
Hi Sharon,
unfortunately, your previous comments lost the actual code formatting you inserted so I can’t really see what you have been trying. Please use the <code>[your code here]</code> tags to insert your code so it preserves the format. Alternatively, use pastebin.com and post a link to your code.
I have tried inserting:
Contact Usinto the product description and it worked fine. This is Magento 1.4.1.1. What version of Magento are you using?Thanks for the reply Robert.
I’m using 1.4.1.1 as well, and it does work in the description (the long one), but the problem is with the short description (“quick overview”).
if I use:
Contact Uswhat i see in the front is:domain.com/contacts/{{store url=I have also tried to do it on a fresh 1.4.1.2 install, and it seems to work on the short description. Could not find the solution/code to the problem in the production site (the one with the bug)
Hi Sharon,
check in your custom template, in the phtml file that renders the short description (usually template/catalog/product/view.phtml) that the short description is output using this code:
< ?php echo $_helper->productAttribute($_product, nl2br($_product->getShortDescription()), 'short_description') ?>Hi,
I have my footer links like:
Contact Us
But when going to the checkout page, the links will remain HTTP, instead of being HTTPS…so they give me an Internet Explorer mixed content error.
Do you know how to prevent this ?
@Niolas If you use:
<a href="{{store url="contacts"}}">Contact Us</a>Your https pages should behave fine. Check your links in the HTML source to see if you have other elements on the page that are using a http url? Any images? Maybe it’s an issue with background images in your CSS?
http links will not cause the warning. The warning is usually caused by images or other media using a non https src.
Hi,
This is great help!
I used this code
<img style="padding: 20px;" src="{{skin url='images/gallery /images/25.jpg'}}"in a static block, intent to get electronics category page, but it’s didn’t work, what else should I do?Thanks in advance!
Hi,
I use direct_url (this part was missing in the last comment) >
<img style="padding: 20px;" src="{{skin url='images/gallery /images/25.jpg'}}"within a static block, intent to get electronics category page when click image, but it’s didn’t work, what else should I do?
Thanks in advance!
got it
Hello and thank you for the article.
How do you tell {{store url=”"}} to use https instead of http?
Magento Wiki does not help a lot here:
http://www.magentocommerce.com/wiki/3_-_store_setup_and_management/cms/markup_tags