@rthur Posted December 23, 2020 Share Posted December 23, 2020 (edited) Hi, I'm trying to display a cms content before my footer. This content must only display if the category page is 10 or 25. I'm not sure the proper way to do it. I tried this : {if $category.id == 10 OR $category.id == 25} {assign var=cms_content value=CMS::getCMSContent(16, true, true)} <div class="contentCms"> {$cms_content.content} </div> {/if} The issue is that it displays the raw html content (see attached). How can I display the code in html format? Thanks Prestashop 1.7.4.3 Edited December 23, 2020 by @rthur (see edit history) Link to comment Share on other sites More sharing options...
ventura Posted December 23, 2020 Share Posted December 23, 2020 Try like this {$cms_content.content nofilter} Link to comment Share on other sites More sharing options...
@rthur Posted December 23, 2020 Author Share Posted December 23, 2020 3 hours ago, ventura said: Try like this {$cms_content.content nofilter} Cheers mate you're a rockstar! Btw what does this nofilter mean exactly ? Is this only to force it to display in html? Link to comment Share on other sites More sharing options...
caoc Posted January 18, 2021 Share Posted January 18, 2021 On 12/23/2020 at 7:27 AM, @rthur said: Hi, I'm trying to display a cms content before my footer. This content must only display if the category page is 10 or 25. I'm not sure the proper way to do it. I tried this : {if $category.id == 10 OR $category.id == 25} {assign var=cms_content value=CMS::getCMSContent(16, true, true)} <div class="contentCms"> {$cms_content.content} </div> {/if} The issue is that it displays the raw html content (see attached). How can I display the code in html format? Thanks Prestashop 1.7.4.3 Please can you give me the path of the file to edit (.tpl) Link to comment Share on other sites More sharing options...
caoc Posted January 24, 2021 Share Posted January 24, 2021 On 12/23/2020 at 2:23 PM, ventura said: Try like this {$cms_content.content nofilter} Please can you give me the path of the file to edit (.tpl) Link to comment Share on other sites More sharing options...
sirego Posted November 30, 2021 Share Posted November 30, 2021 Hi, I display CMS content in a product page within a popup but the different translations are not retrieved when I change the language and it always displays the translation of the first language defined. {if $smarty.get.id_product == 27} {assign var=cms_content value=CMS::getCMSContent(7, true, true)} <div id="productInfoModal" class="modal fade"> <div class="modal-dialog" role="document"><!-- Modal content--> <div class="modal-content"> <button type="button" class="close" data-dismiss="modal" aria-label="Fermer"> <span aria-hiddens="true">×</span> </button> <div class="contentCms modal-body"> {$cms_content.content nofilter} </div> </div> </div> </div> {/if} How to display existing translations when changing the language? Thanks Prestashop 1.7.6.3 Link to comment Share on other sites More sharing options...
Bfn Posted September 2, 2022 Share Posted September 2, 2022 `CMS::getCMSContent(7, true, true)` is wrong. The first argument is the id of the page and the last two are optional. If given, the first one is interpreted as the language id and the second one as the store id. In this case, it’s like using `CMS::getCMSContent(7, 1, 1)` and forcing the language 1 and store 1. The solution is to remove these arguments and keep the defaults, which are the current store and the current language: `CMS::getCMSContent(7)`. Link to comment Share on other sites More sharing options...
ventura Posted September 2, 2022 Share Posted September 2, 2022 Try this {assign var=cms_content value=CMS::getCMSContent(2, $language.id, $shop.id)} Link to comment Share on other sites More sharing options...
Bfn Posted September 2, 2022 Share Posted September 2, 2022 It’s even simpler like this: {assign var=cms_content value=CMS::getCMSContent(2)} Link to comment Share on other sites More sharing options...
ventura Posted September 2, 2022 Share Posted September 2, 2022 27 minutes ago, Bfn said: It’s even simpler like this: {assign var=cms_content value=CMS::getCMSContent(2)} Not if you want it to work correctly in multi-language and multi-store environments. * @param int $idCms * @param int|null $idLang * @param int|null $idShop * * @return array|bool|object|null */ public static function getCMSContent Link to comment Share on other sites More sharing options...
Bfn Posted September 2, 2022 Share Posted September 2, 2022 It does work correctly in multi-language and multi-store environments. If you don’t explicitely pass these values they are pulled from the current environment. `Configuration::get` works exactly the same way, and it’s used everywhere in the core without explicitely passing the language/shop ids. public static function getCMSContent($idCms, $idLang = null, $idShop = null) { if (null === $idLang) { $idLang = (int) Configuration::get('PS_LANG_DEFAULT'); } if (null === $idShop) { $idShop = (int) Configuration::get('PS_SHOP_DEFAULT'); } // ... 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