Hisashi Posted July 6, 2021 Share 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? Link to comment Share on other sites More sharing options...
403 - Forbiddeen Posted July 7, 2021 Share 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/ Link to comment Share on other sites More sharing options...
Hisashi Posted July 7, 2021 Author Share 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 Link to comment Share on other sites More sharing options...
Solution opentype Posted July 7, 2021 Solution Share 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 Link to comment Share on other sites More sharing options...
Hisashi Posted July 7, 2021 Author Share 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 Link to comment Share on other sites More sharing options...
opentype Posted July 7, 2021 Share Posted July 7, 2021 See my code example. You need to use the variables directly, not {like this}. This code is not “template output”. Link to comment Share on other sites More sharing options...
Hisashi Posted July 7, 2021 Author Share 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 Link to comment Share on other sites More sharing options...
403 - Forbiddeen Posted July 7, 2021 Share Posted July 7, 2021 1 hour ago, Hisashi said: That's not quite what I want to do Sorry. Link to comment Share on other sites More sharing options...
Recommended Posts