Home
Forums
New posts
Search forums
What's new
New posts
New media
New media comments
New resources
New profile posts
Latest activity
Media
New media
New comments
Search media
Resources
Latest reviews
Search resources
Members
Current visitors
New profile posts
Search profile posts
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Home
Forums
XenForo bug reports
Resolved bug reports
Default template parameters not available in API requests
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="AddonsLab" data-source="post: 1540212" data-attributes="member: 137157"><p>Some API requests render templates, for example, [ICODE]/nodes[/ICODE] endpoint renders the content of [ICODE]Page[/ICODE] nodes. If these pages happen to use variables otherwise available in templates, e.g. [ICODE]$xf.visitor[/ICODE] the variables are not available and may also log an error if a method is called, e.g. [ICODE]$xf.visitor.canStartConversation()[/ICODE].</p><p></p><p>To reproduce the issue create any [ICODE]Page[/ICODE] node with the following content:</p><p></p><p>[CODE]Hello {$xf.visitor.user_id}!</p><p>[/CODE]</p><p></p><p>The expected outcome is "Hello 0!", the actual outcome is "Hello !".</p><p></p><p>The reason the variables are missing is that [ICODE]App::getGlobalTemplateData()[/ICODE] method is never called in API requests and its output is not added to the default template parameters.</p></blockquote><p></p>
[QUOTE="AddonsLab, post: 1540212, member: 137157"] Some API requests render templates, for example, [ICODE]/nodes[/ICODE] endpoint renders the content of [ICODE]Page[/ICODE] nodes. If these pages happen to use variables otherwise available in templates, e.g. [ICODE]$xf.visitor[/ICODE] the variables are not available and may also log an error if a method is called, e.g. [ICODE]$xf.visitor.canStartConversation()[/ICODE]. To reproduce the issue create any [ICODE]Page[/ICODE] node with the following content: [CODE]Hello {$xf.visitor.user_id}! [/CODE] The expected outcome is "Hello 0!", the actual outcome is "Hello !". The reason the variables are missing is that [ICODE]App::getGlobalTemplateData()[/ICODE] method is never called in API requests and its output is not added to the default template parameters. [/QUOTE]
Insert quotes…
Verification
Post reply
Home
Forums
XenForo bug reports
Resolved bug reports
Default template parameters not available in API requests
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.
Accept
Learn more…
Top