need4speed Posted November 22, 2010 Share Posted November 22, 2010 Is it possible to include the content from one of the CMS pages into my template so I can easily edit it from the administration? Link to comment Share on other sites More sharing options...
rocky Posted November 26, 2010 Share Posted November 26, 2010 Sure, just add code like the following to the PHP file that loads the TPL file: $cms = new CMS(1, intval($cookie->id_lang)); if (Validate::isLoadedObject($cms)) $smarty->assign('content', $cms->content); Change 1 to the ID of the CMS page you want to get the content from, then add {$content} in the TPL file where you want the content displayed. 4 Link to comment Share on other sites More sharing options...
Susi Posted December 2, 2010 Share Posted December 2, 2010 thank you so much for this solution! Now I can have a price-drop page with a custom (via BO) "promotion" content! yeeiii! Link to comment Share on other sites More sharing options...
need4speed Posted December 3, 2010 Author Share Posted December 3, 2010 Yeah it was a perfect answer. Thank you very much Rocky! Link to comment Share on other sites More sharing options...
magazinproba Posted December 12, 2010 Share Posted December 12, 2010 im new in this php thing.can you tell where can i find the tpl or where can i add this code more exactly? Link to comment Share on other sites More sharing options...
need4speed Posted January 14, 2011 Author Share Posted January 14, 2011 All the .tpl files is in the themes folder By the way Rocky can you give me an example how to ride and if, else statement in prestashop?Eg. if ID = 89 then ... I hope you can write me an example it could be really useful. Link to comment Share on other sites More sharing options...
rocky Posted January 15, 2011 Share Posted January 15, 2011 In PHP files: if ($id == 89) { ... } else { ... } In TPL files: {if $id == 89} ... {else} ... {/if} Link to comment Share on other sites More sharing options...
need4speed Posted January 15, 2011 Author Share Posted January 15, 2011 Thank you Rocky i will try it later on.! Link to comment Share on other sites More sharing options...
SpirusTheVirus Posted February 7, 2011 Share Posted February 7, 2011 Hi i am new on php and in this forum and i have the same problem!I read the instructions above but i can't find the specific files to edit.Can you please be more specific on which files i need to edit exactly?I need to add a new page under terms-and-conditions-of-use for returns & exchange.Please assist!Thank you in advance Spyros. Link to comment Share on other sites More sharing options...
rocky Posted February 8, 2011 Share Posted February 8, 2011 I don't understand. Why don't you just edit the "Terms and conditions" page or create a new CMS page? Perhaps I've misunderstood, but it sounds like you want to have two separate CMS pages displayed on the one CMS page. Link to comment Share on other sites More sharing options...
SpirusTheVirus Posted February 8, 2011 Share Posted February 8, 2011 After a better searching on the prestaShop forum i finally found my way to the solution on my problem!Thank you in advance for your efforts!It seems that i had to go to Back Office >> Tools >> CMS and click Add new to create my new page and then at Modules edit the module Info block v1.1 by clicking Configure and enable the page i created by selecting the check box.Thats about all now i can add anything i want!Spyros. 1 Link to comment Share on other sites More sharing options...
affect Posted April 1, 2011 Share Posted April 1, 2011 I've got a related but a bit different question so I'll ask it here: can I make the CMS module display a custom template as one of it's pages instead of pure text? Link to comment Share on other sites More sharing options...
mecollectibles Posted April 4, 2011 Share Posted April 4, 2011 Would you please give thumbnail of how the page will look then?I am not good in programming & would prefer to see pictures before I make the changes. Link to comment Share on other sites More sharing options...
sura Posted August 11, 2011 Share Posted August 11, 2011 Sure, just add code like the following to the PHP file that loads the TPL file:<br/><br/> <br/>$cms = new CMS(1, intval($cookie->id_lang));<br/>if (Validate::isLoadedObject($cms))<br/> $smarty->assign('content', $cms->content);<br/> <br/><br/>Change 1 to the ID of the CMS page you want to get the content from, then add {$content} in the TPL file where you want the content displayed. I followed this step. But I am not able to do it succesfully in Presta 1.4 .. It is displaying the word Array.. Kindly please help Link to comment Share on other sites More sharing options...
rocky Posted August 12, 2011 Share Posted August 12, 2011 That happens when a language hasn't been specified, so it returns all the languages. The language is being specified in my code above though. Check to make sure $cookie->id_lang isn't returning 0. Perhaps you forgot to add global $cookie; to the top of the function? Link to comment Share on other sites More sharing options...
Alex12 Posted September 30, 2011 Share Posted September 30, 2011 Hello Rocky, Thanks for your explanation. I have tested that to add content of a csm page in the footer... I have added in blockcms.php in line 734 public function hookFooter() like this: public function hookFooter() { global $smarty; if (Configuration::get('FOOTER_BLOCK_ACTIVATION')) { $cms = new CMS(7, intval($cookie->id_lang)); if (Validate::isLoadedObject($cms)) $cms_titles = self::getCMStitlesFooter(); $smarty->assign(array( 'block' => 0, 'cmslinks' => $cms_titles, 'content' => $cms->content, 'theme_dir' => _PS_THEME_DIR_, 'display_stores_footer' => Configuration::get('PS_STORES_DISPLAY_FOOTER'), 'display_poweredby' => ((int)Configuration::get('FOOTER_POWEREDBY') === 1 || Configuration::get('FOOTER_POWEREDBY') === false) )); return $this->display(__FILE__, 'blockcms.tpl'); } return ''; } and in blockcms.tpl <div>{$content}</div> But it displays Array What is wrong in my method? Thnak you very much for your help. Link to comment Share on other sites More sharing options...
MarcusAT Posted November 13, 2011 Share Posted November 13, 2011 I am having the same problem with 'Array', am using 1.4, and have tried creating a controller override but it doesn't seem to work. Any clues how to do this for Prestashop 1.4? Thanks! Hello Rocky, Thanks for your explanation. I have tested that to add content of a csm page in the footer... I have added in blockcms.php in line 734 public function hookFooter() like this: and in blockcms.tpl But it displays Array What is wrong in my method? Thnak you very much for your help. Link to comment Share on other sites More sharing options...
lekvarnik Posted November 14, 2011 Share Posted November 14, 2011 It is not working in prestashop 1.4 Link to comment Share on other sites More sharing options...
need4speed Posted November 14, 2011 Author Share Posted November 14, 2011 Yeah it could be really nice to get an update for 1.4.xxx Link to comment Share on other sites More sharing options...
wal_toor Posted November 30, 2011 Share Posted November 30, 2011 So, to do this for 1.4.xx you need to change the blockcms.php file in the blockcms module directory. In my case I needed a CMS text in the footer. To do this find the function "public function hookFooter()" on line747, add the code described in the first post: public function hookFooter() { global $smarty; if (Configuration::get('FOOTER_BLOCK_ACTIVATION')) { $cms_titles = self::getCMStitlesFooter(); $smarty->assign(array( 'block' => 0, 'cmslinks' => $cms_titles, 'theme_dir' => _PS_THEME_DIR_, 'display_stores_footer' => Configuration::get('PS_STORES_DISPLAY_FOOTER'), 'display_poweredby' => ((int)Configuration::get('FOOTER_POWEREDBY') === 1 || Configuration::get('FOOTER_POWEREDBY') === false) )); // custom code global $cookie; $cms = new CMS(7, intval($cookie->id_lang)); if (Validate::isLoadedObject($cms)) $smarty->assign('footercontent', $cms->content); // end custom code return $this->display(__FILE__, 'blockcms.tpl'); } return ''; } Where in this line '$cms = new CMS(7, intval($cookie->id_lang));' the number is the ID of the CMS page. Now open the 'blockcms.tpl' file and add the variable wherever you want. In my case it was: <div id="footertext">{$footercontent}</div> Hope this helps for you. greetz, walter Link to comment Share on other sites More sharing options...
Alex12 Posted January 8, 2012 Share Posted January 8, 2012 Yes! to make a short explanation: the probleme is lang cookies You need to make $cookies global in the function: global $cookie; LIKE THAT public function hookRightColumn() { global $smarty; global $cookie; $cms_right = new CMS(8, intval($cookie->id_lang)); if (Validate::isLoadedObject($cms_right)).... Link to comment Share on other sites More sharing options...
mirni Posted January 18, 2012 Share Posted January 18, 2012 Please, can anyone tell me how I can make CMS links to go 1st , right before variouslinks. I have pages like "home" and "disclaimer" at the end of the line when they should be at the begining. How can I alter the order? Link to comment Share on other sites More sharing options...
need4speed Posted January 18, 2012 Author Share Posted January 18, 2012 What prestashop version are you using? Link to comment Share on other sites More sharing options...
mirni Posted January 18, 2012 Share Posted January 18, 2012 the lastest Link to comment Share on other sites More sharing options...
mr.moonkey Posted February 6, 2013 Share Posted February 6, 2013 back to the first question for ps 1.5.3.1 how to show content of CMS page in tpl page? i would love to have Terms and Conditions CMS page on quick-order and it seems like it would be helpful for many other places Link to comment Share on other sites More sharing options...
kiranrathod Posted February 23, 2013 Share Posted February 23, 2013 I placed the module in the footer and i transferred the same module into all product detail page. now the problem is i want to show different things from the module in footer and different into product details page. just i need the condition like if(module hooked into footer){ // code to be executed } else{ //remaining code } can any one help me please!! Link to comment Share on other sites More sharing options...
ocverclock Posted February 28, 2013 Share Posted February 28, 2013 we could adapt the choice of cms page in a call option feature page with the value No. of cms page? Link to comment Share on other sites More sharing options...
ocverclock Posted March 1, 2013 Share Posted March 1, 2013 I assigned the display of a feature CMS product, which has the id # 6. for that product in feature I can choisire page posted. But I can not retrieve this value has to bring up the desired CMS. {foreach from=$features item=feature} {if isset($feature.value)} {if {$feature.id_feature|escape:'htmlall':'UTF-8'} == 6} {$nbr_page = $feature.value} {$my_page->content} {/if} {/if} {/foreach} and in the productcontroll $my_page =new CMS($nbr_page,self::$cookie->id_lang); self::$smarty->assign('my_page',$my_page); but here it does not work can you help me ? Link to comment Share on other sites More sharing options...
ocverclock Posted March 6, 2013 Share Posted March 6, 2013 after correction for variable assignment, it gives it {foreach from=$features item=feature} {if isset($feature.value)} {if $feature.id_feature == 6} {assign var=nbr_page value=$feature.value} {$my_page->content} {/if} {/if} {/foreach} a thank you to rocky, but here the variable fails to ControllerProduct for CMS generates the page. I was parvien make it appear that saisisant in a variable in the same page (controllerProduct), which does not allow me to recover my information to choose the page (which I selected in the characteristic 6), which provides: $nbr_page = 4; $my_page =new CMS($nbr_page,self::$cookie->id_lang); self::$smarty->assign('my_page',$my_page); someone would have a clue? Link to comment Share on other sites More sharing options...
evox95 Posted August 5, 2014 Share Posted August 5, 2014 http://blog.goldenapp.eu/en/prestashop-cms-page-content-template-file-tpl Link to comment Share on other sites More sharing options...
miki22 Posted September 19, 2014 Share Posted September 19, 2014 Sure, just add code like the following to the PHP file that loads the TPL file: $cms = new CMS(1, intval($cookie->id_lang));if (Validate::isLoadedObject($cms)) $smarty->assign('content', $cms->content); Change 1 to the ID of the CMS page you want to get the content from, then add {$content} in the TPL file where you want the content displayed. This should work for a Front Office: $cms = new CMS(1, intval($this->context->cookie->id_lang)); if (Validate::isLoadedObject($cms)) $this->context->smarty->assign('content', $cms->content); Link to comment Share on other sites More sharing options...
yashman Posted February 16, 2015 Share Posted February 16, 2015 Although this post is solved and little old but thought of sharing a nice and hassle free solution list @ http://nik.chankov.net/2012/06/05/prestashop-adding-text-blocks-in-the-template/ Link to comment Share on other sites More sharing options...
Recommended Posts