ON_PAGE template variable is blank.

Get help with installation and running phpBB 3.1.x here. Please do not post bug reports, feature requests, or extension related questions here.
Ideas Centre
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTE: phpBB 3.1.x is at its End of Life stage and support will NOT be provided after July 1st, 2018.
Locked
jerred121
Registered User
Posts: 3
Joined: Thu Jun 04, 2015 5:42 am

ON_PAGE template variable is blank.

Post by jerred121 »

I tried adding:

Code: Select all

<script>console.log('ON: ' + {{ON_PAGE}});</script>
I basically every form I could think off (alert, 1 set of curly braces, quotes, etc), but it appears ON_PAGE just doesn't produce anything. I also tried it in on viewforum_body.html and pagination.html - no luck anywhere, anyway.

How can I get the current page number?

As a bonus question, is there any better documentation for the the available template variables? I'm finding out it depends on where you call them, but without adequate documentation they might as well be random. I've already spent hours scouring the forums and https://wiki.phpbb.com/Category:Template_Variables.

Bonus question v2: Why is phpbb 3.1 using twig 1.20.0? Has anyone updated to the latest version? The composer manifest just says "1.*", but the phpBB guide says only 1.13.2 is accepted. There's a dump() function in 1.5 (http://twig.sensiolabs.org/doc/functions/dump.html) that seems like it could be useful when determining what objects and variables are available, and when. Anyone tried twig 1.5? Are there any "safer" alternatives?

Thanks, I'm a fairly seasoned dev, but i'm really struggling with the proprietary, and limitations of some things in phpBB. I'm sure I'll get it, but tasks that should only take me a couple hours are taking days.
User avatar
Oyabun1
Former Team Member
Posts: 23162
Joined: Sun May 17, 2009 1:05 pm
Location: Australia
Name: Bill

Re: ON_PAGE template variable is blank.

Post by Oyabun1 »

jerred121 wrote:How can I get the current page number?
{ON_PAGE} isn't defined as a template variable, use {CURRENT_PAGE}.
                      Support Request Template
3.0.x: Knowledge Base Styles Support MOD Requests
3.1.x: Knowledge BaseStyles SupportExtension Requests
jerred121
Registered User
Posts: 3
Joined: Thu Jun 04, 2015 5:42 am

Re: ON_PAGE template variable is blank.

Post by jerred121 »

Thanks, that did the trick. Sorry for the late reply.

So is there a way to dump Twig variables? I'd like to convert as much of the old proprietary syntax over to twig as much as possible, but in viewforum_body.html when I change:

Code: Select all

<!-- IF not S_IS_BOT and U_MARK_TOPICS and .topicrow -->
with

Code: Select all

{% if not S_IS_BOT and U_MARK_TOPICS and .topicrow %}
I get the following error:

Code: Select all

Fatal error: Uncaught exception 'Twig_Error_Syntax' with message 'Unexpected token "punctuation" of value "." in "viewforum_body.html" at line 40.' in C:\xampp\htdocs\vendor\twig\twig\lib\Twig\ExpressionParser.php:190...
Seems like twig doesn't like the '.' variables, but I'm unsure of what class they belong to or how to use them in Twig.
Locked

Return to “[3.1.x] Support Forum”