Jump to content

Retrieve the title of a CMS page


Recommended Posts

Good morning, everyone,

I'm trying to do something simple, but I can't find any resources, either in the doc or on the web.

I'm just looking to add CMS links to a template.

For the URL, no problem: {url entity='cms' id='1'}

But to get the title of the page from the ID, I searched everywhere, tested a bunch of variables, but impossible.

Any idea of the procedure?

Link to comment
Share on other sites

  • 1 year later...

Add below function in classes/Tools.php

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

And use this function in your tpl.

<a href="{$link->getCMSLink(3)}">{Tools::getCMSTitle(3, $language.id)}</a>

Here 3 is id_cms.

  • Like 2
Link to comment
Share on other sites

  • 2 weeks later...

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