Jump to content
thirty bees forum
  • 0

Get page titles with smarty


Coachonko

Question

I can get links to pages with the following smarty tags 

{$link->getPageLink('contact')|escape:'html':'UTF-8'}
{$link->getCategoryLink(4)|escape:'html':'UTF-8'}
{$link->getCmsLink(9)|escape:'html':'UTF-8'}

Is there a way to get page titles instead of having to use the {l s='title'} tags?

Edited by Coachonko
Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

It's doable, but not very friendly. Look what static methods are available in Meta class. You could you getMetaByPage, or getCategoryMetas or getCmsMetas

{assign var='contactMeta' value=Meta::getMetaByPage('contact', $lang_id)}
{assign var='categoryMeta' value=Meta::getCategoryMetas(4, $lang_id, 'category')}
{assign var='cmsMeta' value=Meta::getCmsMetas(9, $lang_id, 'cms')}
<pre>
  contact title = {$contactMeta.title}
  category title = {$categoryMeta.meta_title}
  cms title = {$cmsMeta.meta_title}
</pre>

 

Link to comment
Share on other sites

  • 0

Thanks! This can be very useful when there is a large amount of these links, dynamically getting title is much faster than editing translations.

6 hours ago, datakick said:

It's doable, but not very friendly. Look what static methods are available in Meta class. You could you getMetaByPage, or getCategoryMetas or getCmsMetas


{assign var='contactMeta' value=Meta::getMetaByPage('contact', $lang_id)}
{assign var='categoryMeta' value=Meta::getCategoryMetas(4, $lang_id, 'category')}
{assign var='cmsMeta' value=Meta::getCmsMetas(9, $lang_id, 'cms')}
<pre>
  contact title = {$contactMeta.title}
  category title = {$categoryMeta.meta_title}
  cms title = {$cmsMeta.meta_title}
</pre>

 

contactMeta works perfectly

categoryMeta works but it seems like thirty bees appends the name of the website to the title, so the output should be processed.

The cmsMeta doesn't seem to work.

If how do you fetch the name of the page instead of the meta title?

Edited by Coachonko
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...