Jump to content

Help customize meta tags


Hisashi
 Share

Go to solution Solved by opentype,

Recommended Posts

Hello,

I want to make a custom meta description in Pages > Record

I tried using code and it didn't work, how do I provide the following data in tag...

  • Article title
  • Field > template key

Tried something like this but the codes don't work

Screenshot_37.thumb.png.d5567627b2c985765d8b6e2f3c6bcb24.png

 

Any tips?

Link to comment
Share on other sites

1 hour ago, 403 - Forbiddeen said:

Maybe this will help you : 

Working fine with 4.6.x

image.png.ab32f8edde2ac9ce759369765cc7fe2b.png

See my source code: view-source:https://ggames.com.br/files/file/3405-trainer-police-stories-mrantifun/

 

 

 

That's not quite what I want to do

Link to comment
Share on other sites

  • Solution
Posted (edited)
20 hours ago, Hisashi said:

Any tips?

The meta tags can be overridden from any Pages template used to render the current page. You can add variables there as well. 

{{\IPS\Output::i()->metaTagsTitle = "Whatever ".$something ;}}
{{\IPS\Output::i()->metaTags['og:description'] = "Something else" ;}}

You can put that into the record template for example. 

Edited by opentype
Link to comment
Share on other sites

Posted (edited)
27 minutes ago, opentype said:
{{\IPS\Output::i()->metaTags['og:description'] = "Something else" ;}}

 

That's exactly what I was looking for!

I just had a little problem, it doesn't allow me to use template key field, an error appears, do you know how to solve it?

Screenshot_39.png.7fc1255a5189519f8037004000421c82.png
 

How do I want it to look for example:

{{\IPS\Output::i()->metaTags['og:description'] = "Read more about {$record->_title}. By {$record->customFieldDisplayByKey('author', 'raw')|raw}" ;}}

It is not accepting customFieldDisplayByKey

Edited by Hisashi
Link to comment
Share on other sites

Posted (edited)
9 minutes ago, opentype said:

See my code example. You need to use the variables directly, not {like this}. This code is not “template output”. 

I managed to solve it, just remove the code "|raw"

 

Edited by Hisashi
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...

Important Information

We use technologies, such as cookies, to customise content and advertising, to provide social media features and to analyse traffic to the site. We also share information about your use of our site with our trusted social media, advertising and analytics partners. See more about cookies and our Privacy Policy