Jump to content

[solved]Get cms page title from child categories does not load


Poehnixzz

Recommended Posts

Hello,

I am trying to get the child title from the categories.

I already tried this: theme/classic/templates/cms/category.tpl

{foreach from=$sub_categories item=sub_category}
<li class="col-md-3">
  <a href="{$sub_category.link}"><h2>{$sub_category.name}</h2></a>
  {foreach from=CMS::getCMSPages({$cookie->id_lang|intval},{$sub_category.id_cms_category},true) item=cmspages}
  <p>
    <a href="{$link->getCMSLink($cmspages.id_cms, $cmspages.link_rewrite)|escape:'htmlall':'UTF-8'}">
      {$cmspages.meta_title|escape:'htmlall':'UTF-8'}
    </a>
  </p>
  {/foreach}
</li>
{/foreach}

The link is showing correctly, but when I want to get the name out of the url, it is not working.

PrestaShop version: 1.7.6.9

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

I solved this issue!

I added this to classes/Tools.php

public static function getCMSTitle($id_cms,$id_lang){
$cms = new CMS($id_cms, $id_lang);
return $cms->meta_title;
}

Then you can call this in the category.tpl

<a href="{$link->getCMSLink(1)}">{Tools::getCMSTitle(1,$cookie->id_lang)}</a>

Bron:

https://toniravsadhu.wordpress.com/2014/02/27/prestashop-how-can-i-get-a-cms-page-title-in-a-tpltemplate-file/

Link to comment
Share on other sites

  • Poehnixzz changed the title to [solved]Get cms page title from child categories does not load

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...