Override pages/posts metadata for custom templates
Created 8 years ago by hugogilmarHi,
I'm trying to override posts module behaviour for public templates. I need to add metadata on templates like opengraph/twitter cards info (custom fields added to page/posts streams) to Post/Page loader class.
I'm working on a extra theme for my project, what you guys recommend, should I override these classes? (I don't have any idea how to do that) or working with twig deferred block calling $template->set on templates for my extra metadata?. I don't want to use page or post helper, so I can have a standard template for those.
I hope you can understant what I'm asking about.
Thanks
hugogilmar
—
8 years ago
It works! Thanks.
I would approach it this way:
Add your block of code in metadata and assume there is a
template.post
value:There are a lot of ways you can do this - but this is most likely the easiest / fastest. You can add another
if
statement fortemplate.page
for example. Most of the core addons add contextual stuff that's being "viewed" to the template super variable.Hope this helps!