4

I know I can link to any category by using:

<a href="magento-store.com/category">Category</a>

But I was wondering if there was a way to do something like this:

<a href="{{url=category ID}}">Category</a>

I haven't been able to find anything like that. Thank you!

2 Answers 2

9

Use the category link widget. Let's say you want to add a link to category with ID 12. Add this to your cms page/block:

{{widget type="catalog/category_widget_link" anchor_text="Some text" title="Some text" template="catalog/category/widget/link/link_inline.phtml" id_path="category/12"}}

This will generate:

<a href="http://mysite.com/category/path.html" title="Some text">Some text</a>

If you don't add the parameters andchor_text and title the category name will be used.

6
  • Is there a way I can include HTML inside the category link widget? Commented Jun 15, 2013 at 12:27
  • What do you mean? Give me an example.
    – Marius
    Commented Jun 15, 2013 at 14:14
  • For example, if I wanted to create a hyperlink around an image like so. <a href="mysite.com/category/path.html" title="Some text"><img src="imgsource.jpg" /></a> Commented Jun 16, 2013 at 0:44
  • The parameter anchor_text is the text inside the <a> tag. I'm not sure you can add <img /> tags, but you can try.
    – Marius
    Commented Jun 16, 2013 at 11:36
  • <img /> not working in anchor_text parameter. Isn't there any other way to link image to category? Commented Dec 23, 2013 at 12:03
0

The linking structure in magento is a mess. CMS pages without closing braces and Categorry pages with. The answer here also omits to inform you that using the widgets prepends the URL with the store identifiers which add a whole new level of mess at the end of the URL which requires changes to the .htaccess file.

The manual way I would recommend however as stated in previous posts this may lead to broken links when url are updated or categories renamed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.