dskarbek Posted April 3, 2015 Share Posted April 3, 2015 Hi, I try to add CMS content in product.tpl file. I create file: override/classes/Tools.php with data: <?php /** * Tools override class */ class Tools extends ToolsCore{ public static function getContent($id_cms){ $sql = 'SELECT l.`id_lang`, c.`content` FROM `'._DB_PREFIX_.'cms_lang` AS c LEFT JOIN `'._DB_PREFIX_.'lang` AS l ON c.`id_lang` = l.`id_lang` WHERE c.`id_cms` = '.(int)$id_cms.' AND l.`active` = 1'; $page = $DB::getInstance()->getRow($sql); return $page['content']; } } In product.tpl I tried this: <div id="delivery" class="rte" style="display:none">{Tools::getContent(1)} Unfortunatly it doesn't work... Can you help me? Best regards, Darek Link to comment Share on other sites More sharing options...
MichałM Posted April 4, 2015 Share Posted April 4, 2015 (edited) In my opinion better way is to create custom field in Prestashop product back-office. Example tutorial: nemops.com/prestashop-products-new-tabs-fields/ And then in override/controllers/front/ProductController.php write something like this: public function initContent() { parent::initContent(); $id_cms = $this->product->CUSTOM_FIELD_NAME; $cms = new CMS($id_cms, intval(Context::getContext()->language->id)); if (Validate::isLoadedObject($cms)) self::$smarty->assign('text_cms', $cms->content); } Where value of CUSTOM_FIELD_NAME is number of cms page. And in product.tpl: <div id="delivery" class="rte"> {$text_cms} </div> This is only my proposition... Edited April 4, 2015 by MichałM (see edit history) 1 Link to comment Share on other sites More sharing options...
dskarbek Posted April 7, 2015 Author Share Posted April 7, 2015 Hi Michał, Dziękuję bardzo I modified my function and it works. I did in override/classes/Tools.php: class Tools extends ToolsCore{ public static function getContent($id_cms){ $cms = new CMS($id_cms, intval(Context::getContext()->language->id)); return $cms->content; } } And in product.tpl: <div id="delivery" class="rte" style="display:none">{Tools::getContent(1)} and it works. Thank you again Best regards, Darek Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now