Sometimes you may want to override the open graph protocols in your Pages templates, especially when it comes to description and image that is used when sharing your pages. Whie you do not have access to the meta information in your templates, there is a nifty little trick you can use to target these specifically:
{{\IPS\Output::i()->metaTags['description'] = $record->customFieldDisplayByKey('YOUR_CUSTOM_FIELD', 'listing');}} {{\IPS\Output::i()->metaTags['og:description'] = $record->customFieldDisplayByKey('YOUR_CUSTOM_FIELD', 'listing');}} {{\IPS\Output::i()->metaTags['og:image'] = $record->customFieldDisplayByKey('YOUR_CUSTOM_FIELD', 'listing');}}
This example show both the open graph protocol tags, but you also see that we can target our standard meta tags as well.
The first part defines what tag we want to target. After the equal sign, we then define what field we want to use as the new data for that field. In this example, we have defined that we want the output from the listing settings in that custom field, but you can choose display and/or escape with |raw as usual.
Recommended Comments
There are no comments to display.
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now