1

I have a category page called "team", which is nested in my menu structure.

How can I link to that page and url, from within a phtml page elsewhere? I am of course wanting it to be dynamic.

For images I've been using:

echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).

but I am currently braindead on how to do that with category pages.

(side note - I use multi-language, multi-views.)

2
  • for the moment, I now use this: <a href="<?php echo Mage::getUrl('', array('_direct'=>'company/team.html'))?>">meet the complete team</a>
    – egg
    Jul 26, 2014 at 12:40
  • but this won't work when I change my store view to another language, with differing page names etc? Is there a method which is multi-language, multi-shop-view safe? thanks!
    – egg
    Jul 26, 2014 at 12:40

1 Answer 1

2

You can create a link with current web URL by using

Mage_Core_Model_Store::URL_TYPE_WEB

i.e.

<a href="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB).'company/team.html'?>">meet the complete team</a>

Then to make it internationalized ... 1 approach that comes to mind (and after consulting with google for something better) ... is to add translation.

If you are using a your own module for the above changes, you can:

  1. for example for a Italian storeview, create an YourNamespace_YourModule.csv at app/locale/it_IT/
  2. in that /it_IT/YourNamespace_YourModule.csv add the following lines

    "company/team","società/squadra"

    where ""società/squadra" are the names of the category/sub in Italian and

    "meet the complete team","the link text in Italiano goes here"

  3. after that modify the link to be

    <?php $my_helper = Mage::getHelper('yournamespace_yourmodule')?>
    <a href="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB).$my_helper->__('company/team')'.html'?>"><?php echo $my_helper->__('meet the complete team')</a>
    

    where in Mage::getHelper('yournamespace_yourmodule') 'yournamespace_yourmodule' should be the XML path to your Helper, as defined in your config.xml

  4. repeat for any language/storeview you might need

If you are not using your own helper, you can add the above translations to a core module translation file and call the respective core module Helper in the link.

Hopefully, someone of the Magento gurus could provide a more canonical approach to the task, if not, the outlined approach seems reasonable enough to me.

1
  • thanks for this, I will try it out. Another example would when I switch between German and English, I get either "german/produkte.html" or "english/products.html". But using your solution looks to be the way out there.
    – egg
    Jul 26, 2014 at 17:30

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.