6

In my magento 1.8 project, I have some URL's which are calling some other sites like blogs, youtube videos etc. I want these URL's to keep in admin so that the client/store owner can change them later if needed to.

Where should I keep these URL's such that the client can change them easily? and how to call them in my magento footer template?

3

I suggest you use custom variables for this.

They can be found under System > Custom Variable. You can enter plain text values and HTML values there. The HTML value is optional, plain text must be entered.

The variables can be inserted on CMS Pages via the WYSIWYG Editor ("Insert Variable") or via this code directrly: {{customVar code=blog_link}}.

If you need to include the variables' output in a .phtml file, use this code:

Mage::getModel('core/variable')->loadByCode(blog_link')->getValue('plain');
Mage::getModel('core/variable')->loadByCode(blog_link')->getValue('html');
1

I created a CMS Static Block and added content as just URL and called the same static block in my phtml template using the following code:

<a href="<?php echo strip_tags($this->getLayout()->createBlock('cms/block')->setBlockId('blog_link')->toHtml()); ?>">Blog</a>

Now the user just need to change the content in that Static block to change the URL.

I hope this is the best way to tackle this issue..

  • you could also create your own module and add an admin section using system.xml under system->configuration and get the urls there. get those url using getStoreConfig function in your block and display them in your templates. – Shathish Nov 1 '13 at 8:12
  • @Shathish that is a good idea but I have only few urls (two) so I am going with this approach. – Mr_Green Nov 1 '13 at 8:24
  • 1
    hmmm you're right, writing code for just two url's must be painful. – Shathish Nov 1 '13 at 8:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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