Prestashop :: adding text blocks in the template

Here you can see how you can add html and text on various places of your template.

Presta is very good written e-commerce platform and class overwriing is piece of cake. So, here is the code:

1. Create a file under {presta_dir}/override/classes and name it Tools.php.
2. Copy and paste that code in the new file:

<?php
/**
 * Tools override class
 */

class Tools extends ToolsCore{
    public static function getPage($link_rewrite = null){
        global $cookie;
        $page = Db::getInstance()->getRow("SELECT * FROM "._DB_PREFIX_."cms_lang WHERE id_lang='".(int)($cookie->id_lang)."' AND link_rewrite LIKE '".$link_rewrite."'");
        return $page['content'];
    }
}

Note: if you already have this file just copy only the function and place it inside the Tools class.

3. That’s it 🙂 Go and create a new CMS page under Prestashop Admin (Tools->CMS). Add a nice “friendly url” and put your your text in the body.
4. How to use the function in the template: Go to your template file files and insert the following code:

{Tools::getPage('your-seo-friendly-url-cms-page');}

Don’t forget to delete the cache.

Conclusion: The code is not 100% MVC, but it’s working straight away. As benefit your texts will be multilingual, and especially when you need to put them on places where there is no hooks, This would save a lot of time and effort.

Hope this helps.

Share it:
  • Facebook
  • Twitter
  • Digg
  • StumbleUpon
  • del.icio.us
  • Google Bookmarks
  • Yahoo! Buzz
  • Add to favorites
  • Identi.ca

8 thoughts on “Prestashop :: adding text blocks in the template

  1. PrestaShop templates are built specifically for the platform. Also to that, one could also have an special theme developed for a entirely personalized and specific store.

Leave a Reply

Your email address will not be published. Required fields are marked *