Jump to content

Display content cms page on footer page


@rthur

Recommended Posts

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

Capture d’écran 2020-12-23 à 12.09.28.png

Edited by @rthur (see edit history)
Link to comment
Share on other sites

  • 4 weeks later...
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

Capture d’écran 2020-12-23 à 12.09.28.png

Please can you give me the path of the file to edit (.tpl)

Link to comment
Share on other sites

  • 10 months later...

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

  • 9 months later...

`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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...