1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.5 Updating header for specific templates?

Discussion in 'Styling and Customization Questions' started by Peace, May 2, 2016.

  1. Peace

    Peace Active Member

    I have a few custom pages that use PAGE_CONTAINER.

    I need to add some custom meta information in these pages (specifically og:image and og:title for Facebook). Unfortunately, I can't insert this stuff into page template because that's all within the <body> tags, and the meta information needs to be in the <header> tags.

    This meta information cannot show for other pages that use PAGE_CONTAINER, only these specific ones.

    I tried adding the meta information in PAGE_CONTAINER between some conditionals like:

    <xen:if is="in_array({$contentTemplate}, array('mypage1', 'mypage2'))">

    However, this doesn't work because the templates don't even load until after the header, so it can't detect which template it's in.

    Is there a simple way to modify the header information in some specific templates?

  2. Chris D

    Chris D XenForo Developer Staff Member

    That actually should work. The container should know what content template it is rendering.

    When on these pages, what value is displayed if you add:

    {xen:helper dump, $contentTemplate}

    Aside from this, it is actually possible to inject values into the header from the content template.

    Look for usages of text similar to this in templates for an idea:

    <xen:container var="$head.
    Peace likes this.
  3. Peace

    Peace Active Member

    Perfect, thanks @Chris D! Got it working with the helper function :)
    Chris D likes this.

Share This Page