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

XF 1.4 Possible to Change Page Node <Title> Dynamically?

#1
I have a page node that I control via an external PHP script via a callback. Even though the page node is in actuality many pages, due to the PHP script, the page title is always the same. Is there any way to control the <title> dynamically from my PHP script?
 

Jake Bunce

XenForo moderator
Staff member
#2
The <title> can be set in the content template with this code:

Code:
<xen:title>TITLE HERE</xen:title>
The default content template for all page nodes is:

Admin CP -> Appearance -> Templates -> pagenode_container

For your purposes you probably want to use a callback to set a different content template so you can change the xen:title code for a specific page node. Here is a guide:

https://xenforo.com/community/threads/how-to-change-remove-the-container-from-page-nodes.34154/
 
#3
Thanks—I was able to follow your directions until the last part, because I'm already using the includeFile callback function here. i.e. I can't specify two callbacks on one page node. Is there a solution to this?

Also, I want to make sure we're on the same page that I'm looking to control the title from the PHP file I'm including.
 

Jake Bunce

XenForo moderator
Staff member
#5
I can't be more specific in my instructions. Those are all of the programming tools available which can allow you to:

1) Override the content template for a specific page node.

2) Define the page title in that content template.

Beyond that it is a programming problem that requires more specific questions if I am to help.

Is there any way to control the <title> dynamically from my PHP script?
Note that you can define template variables for use in the content template like this:

Code:
$response->params['customTitle'] = 'Some title here';
That would allow you to use this in your content template:

Code:
<xen:title>{$customTitle}</xen:title>