XF 1.5 How do I add some HTML into the <head> section from a main template?

Stuart Wright

Well-known member
I need to add some code, specifically
HTML:
<meta property="og:image:secure_url" content="@imagePath/editorial/products/{$feature.url}" />
into the head area of our custom review pages.
I guess it's the equivalent of adding custom HTML to the head section of the forum_list page.
How do I do that, please?
 
The forum_list template already does this, you can do the same thing. This should work in any template:
Code:
<xen:container var="$head.image_secure_url"><meta property="og:image:secure_url" content="@imagePath/editorial/products/{$feature.url}" /></xen:container>

The key thing here is the $head variable. It is an array, and it is looped through in the container header. You can add whatever keys you like to the $head variable, in this case, I've called the key "image_secure_url" and given it a value containing the meta property code you want.
 
The forum_list template already does this, you can do the same thing. This should work in any template:
Code:
<xen:container var="$head.image_secure_url"><meta property="og:image:secure_url" content="@imagePath/editorial/products/{$feature.url}" /></xen:container>

The key thing here is the $head variable. It is an array, and it is looped through in the container header. You can add whatever keys you like to the $head variable, in this case, I've called the key "image_secure_url" and given it a value containing the meta property code you want.
Oh this is awesome. I love Xenforo. So many hidden gems. Thanks, Chris.
 
Sort of similarly, that happens like this:

Code:
<xen:container var="$head.openGraph">
    <xen:include template="open_graph_meta">
        <xen:set var="$url">{xen:link 'canonical:forums'}</xen:set>
        <xen:set var="$title">{$xenOptions.boardTitle}</xen:set>
        <xen:set var="$description">{$xenOptions.boardDescription}</xen:set>
        <xen:set var="$ogType">website</xen:set>
    </xen:include></xen:container>

That's from the forum_list template. We don't actually include this automatically in every page though.

Theoretically, you could overwrite the container var value by defining it in the template with the same key, e.g. $head.openGraph and whatever you want the value to be, e.g:

Code:
<xen:container var="$head.openGraph"><!-- Removed og meta data --></xen:container>

That would effectively comment the meta data out if it already exists, I believe.
 
Top Bottom