Hisashi Posted July 6, 2021 Posted July 6, 2021 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 Any tips?
403 - Forbiddeen Posted July 7, 2021 Posted July 7, 2021 Maybe this will help you : Working fine with 4.6.x See my source code: view-source:https://ggames.com.br/files/file/3405-trainer-police-stories-mrantifun/
Hisashi Posted July 7, 2021 Author Posted July 7, 2021 1 hour ago, 403 - Forbiddeen said: Maybe this will help you : Working fine with 4.6.x 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
Solution opentype Posted July 7, 2021 Solution Posted July 7, 2021 (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 July 7, 2021 by opentype Hisashi and Ibai 2
Hisashi Posted July 7, 2021 Author Posted July 7, 2021 (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? 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 July 7, 2021 by Hisashi Ibai 1
opentype Posted July 7, 2021 Posted July 7, 2021 See my code example. You need to use the variables directly, not {like this}. This code is not “template output”.
Hisashi Posted July 7, 2021 Author Posted July 7, 2021 (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 July 7, 2021 by Hisashi Ibai 1
403 - Forbiddeen Posted July 7, 2021 Posted July 7, 2021 1 hour ago, Hisashi said: That's not quite what I want to do Sorry.
Recommended Posts