$staticpage_pagetitle value no longer available

Creating and modifying plugins.
Post Reply
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

$staticpage_pagetitle value no longer available

Post by Don Chambers »

One way templates determine if a page view is, or is not a static page is via $staticpage_pagetitle such as:

Code: Select all

{if $staticpage_pagetitle ==''} {* this is not a static page *}
Prior to s9y 1.7 (or perhaps 1.7.2), the value of $staticpage_pagetitle was available in entries.tpl, and also index.tpl.... but now it seems to only be available within the scope of plugin_staticpage.tpl. Can this be made globally available again, or am I stuck creating a variable and making it scope='root'?
=Don=
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: $staticpage_pagetitle value no longer available

Post by Timbalu »

Hmm, are you really sure about this, Don?
I just wonder, while there are some users out in the wild using this construction, since we would probably have had someone complaining about this in the last or even before in the RC quarter of the year.
Mine are working! In index.tpl:

Code: Select all

<li{if $staticpage_pagetitle == "about"} class="active"{/if}><a href="/blog/pages/about.html">About</a></li>
Or do you mean that there is no empty $staticpage_pagetitle var available any more?
Then you could do

Code: Select all

{if !$staticpage_pagetitle or empty($staticpage_pagetitle)} {* proceed only if this is not a static page *} {/if}
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Re: $staticpage_pagetitle value no longer available

Post by Don Chambers »

Thanks for the reply Ian. Test static page here. plugin_staticpage.tpl, entries.tpl, and index.tpl all modified to include this code:

Code: Select all

static Page page title: "{$staticpage_pagetitle}"; View: "{$view}"
The correct value for the pagetitle is "smart".

It looks like entries.tpl no longer knows value of $staticpage_pagetitle, but index.tpl does (my mistake).
=Don=
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: $staticpage_pagetitle value no longer available

Post by Timbalu »

Could you give me a deeper hint why and how {$staticpage_pagetitle} should be available in entries.tpl?
It is not by default with 1.6.2 with Smarty 2 either.

This is quickly tested with that old Serendipity version (and debug ON):

Only {$staticpage_categorypage} is available and set false.

If I load a staticpage like "about", entries.tpl isn't even processed, since it is not needed.

In a normal startpage it is: Index.tpl static Page page title: ""; View: "start"
In a normal staticpage it is: Index.tpl static Page page title: "about"; View: "plugin"

Maybe I do not get your point. How comes you process entries.tpl on a staticpage?
see here (I think):
https://github.com/s9y/Serendipity/blob ... c.php#L138
Yes, plugin_staticpage.tpl and index.tpl are the ones processed by staticpages, containing the plugin vars. This includes {$CONTENT} being content.tpl, to react on searchresult, content_messages and {$ENTRIES}, {$ARCHIVES}. But the last two (at least the first) set empty in genpage.
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Re: $staticpage_pagetitle value no longer available

Post by Don Chambers »

Timbalu wrote:Could you give me a deeper hint why and how {$staticpage_pagetitle} should be available in entries.tpl?
It is not by default with 1.6.2 with Smarty 2 either.
YL wrote about this nearly 4 years ago, and I then suggested a solution at that time.

The actual Kinetic demo is still running s9y 1.6.2. I modified the same smarty templates in the demo as mentioned above, and this demo static page clearly shows the value of staticpage_pagetitle being correctly emitted within entries.tpl in that version.

The logic {if $staticpage_pagetitle ==''} applies to more than just static pages too... contact form comes to mind, and there may be others.
=Don=
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: $staticpage_pagetitle value no longer available

Post by Timbalu »

I see - this is different to my "normal template" results, as this is kinetic. You know I don't have the (closed) sources, so I can not tell you. :wink: That is why I asked, how you managed to get entries.tpl processed in a staticpage. I just wanted to state by this, that the normal workflow does "not process" entries.tpl on staticpages at all, while set empty.
All the other plugin_contactform.tpl, plugin_guestbook.tpl and so on check correct for $staticpage_pagetitle, this is the same like in plugin_staticpage.tpl. Since this is the normal workflow state, this for sure points to a stricter set scoping usage, which is good in my eyes, since it is closer to the real workflow!

I know about this old YL thread. It is just about the total opposite, since it wants to get rid of an outer div for the empty set {$ENTRIES} - entries.tpl. That is why I already asked, if you mean that there is no empty $staticpage_pagetitle == '' var available any more? And suggested to use:

Code: Select all

    {if !$staticpage_pagetitle or empty($staticpage_pagetitle)} {* proceed only if this is not a static page *} {/if}
instead. (If this may be one of the problems we should check and repair this in all templates)

To give a helping hand on this "scoping issue" in Kinetic, and we know Smarty3 is more straight than its predecessor, I definitely need to know in detail how this is done on your side, to reproduce this behaviour.
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Re: $staticpage_pagetitle value no longer available

Post by Don Chambers »

YL discovered for himself that entries.tpl is processed for static pages - he was not looking at the Kinetic template, he noticed it while developing his own template.

I have yet another sandbox example. This one is running 1.6.2 with bulletproof. I modified entries.tpl to emit a comment at both the beginning and end of entries.tpl. See here: http://www.optional-necessity.com/sandk ... tatic.html.

So, my problem remains.... I need to know the value of $staticpage_pagetitle in entries.tpl. I had no problem with this < s9y 1.7. Evaluating if it is empty is meaningless - it will always be empty if I cannot evaluate it correctly.
=Don=
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Re: $staticpage_pagetitle value no longer available

Post by Don Chambers »

Additionally. I changed the template of my first example to 2k11 under 1.7.2 - I also modified that template's entries.tpl to demonstrate that it too is being processed for static pages: http://www.optional-necessity.com/kinet ... rtcar.html

EDIT: Wait a sec... getting different results.... let me dig deeper. :?
=Don=
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: $staticpage_pagetitle value no longer available

Post by Timbalu »

Don Chambers wrote:Evaluating if it is empty is meaningless - it will always be empty if I cannot evaluate it correctly.
Not true IMHO, since debugging smartified vars does not have it at all (*), unless you tell me how you put entries.tpl into a staticpage. :wink: The issue with asking if $staticpage_pagetitle == '' before, was IMO in reason of Smarty 2 not being strict! It took a question regarding an non existent smarty var to happen true, when asking if its value was an empty string, I assume. Run {debug} on top of entries.tpl to see for yourself. If you ask to display Page page title: "{$staticpage_pagetitle}"; you get Page page title: ""; in both worlds, because it isn't delivered at all.

(*) I only have $staticpage_categorypage available, since we need to know if false or true.

And yes, entries.tpl is processed, via genpage and further on in content.tpl, but set empty on staticpages, ... normally. See that genpage link. If you don't have any $entries or the entries_header, or entries_footer hook, it is just empty. There my question hooks in, why and how do you need $entries in staticpages?
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
Post Reply