Template Developers: Please update entries.tpl!

Skinning and designing Serendipity (CSS, HTML, Smarty)
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Template Developers: Please update entries.tpl!

Post by garvinhicking »

Hi!

Since Serendipity 1.7 we use Smarty3. This requires a small change in templates' entries.tpl files.

Within the main loop for entries:

Code: Select all

{foreach from=$dategroup.entries item="entry"}
you now need to add one line after that loop, so that it looks like this:

Code: Select all

{foreach from=$dategroup.entries item="entry"}
{assign var="entry" value=$entry scope=parent}
This line ensures, that {$entry} will be available in sub-templates like comments.tpl and trackbacks.tpl.

This change does not hurty older installations with Smarty2. If you are distributing commercial templates, you might want to contact your customers to update their templates, once they also upgrade their Serendipity installation to 1.7 (or 2.0).

Regards,
Garvin.
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Template Developers: Please update entries.tpl!

Post by Timbalu »

please better use

Code: Select all

{assign var="entry" value=$entry scope="parent"}
with quotes, or

Code: Select all

{assign var="entry" value=$entry scope="root"}
with works same in this case.
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Re: Template Developers: Please update entries.tpl!

Post by yellowled »

garvinhicking wrote:This requires a small change in templates' entries.tpl files.

Within the main loop for entries:

Code: Select all

{foreach from=$dategroup.entries item="entry"}
you now need to add one line after that loop, so that it looks like this:

Code: Select all

{foreach from=$dategroup.entries item="entry"}
{assign var="entry" value=$entry scope=parent}
I was just thinking, it might not be just that simple. If a template contains .tpl files which also loop through said loop (which happens in complex, magazine-style templates), this would have to be assigned in any .tpl file which uses this loop, wouldn't it?

YL
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Re: Template Developers: Please update entries.tpl!

Post by yellowled »

Happy to announce that all 25 themes which are available on http://yellowled.de/templates.html and http://yellowled.de/ports.html have just been updated with the compatibility code as provided by Garvin. Of course, you still need to update them manually.

(Gosh, I hope we're not going to have something similar anytime soon.)

YL
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Template Developers: Please update entries.tpl!

Post by Timbalu »

(Yes, I know its working without, ) but why without the quotes? This is much cleaner code {as you can use simple value=$foo vars without or complicated ones with backticks or {$bar} - and every string usage better as a quoted "string". If we/you have to change every single template we can reach it is better to do it right, IMHO.
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Re: Template Developers: Please update entries.tpl!

Post by yellowled »

Can't really say. I'm just assuming Garvin's code is okay.

This assumption worked quite well over the past … wow, it's been seven years. :)

YL
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Template Developers: Please update entries.tpl!

Post by garvinhicking »

Hi!

We'll stick to the working version now, I'd say. If there are no more objections I'll try to put up rc2 somewhen tomorrow!

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Template Developers: Please update entries.tpl!

Post by Timbalu »

I don't really understand these two answers ... :?
I was talking about the better/cleaner use of quoting for the scope parent string only, which is done now. And I'm happy! :P
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Re: Template Developers: Please update entries.tpl!

Post by yellowled »

garvinhicking wrote:We'll stick to the working version now, I'd say. If there are no more objections I'll try to put up rc2 somewhen tomorrow!
I was a tad quicker in replacing them with the quoted version this afternoon, which explains Timbalus confusion. :)

YL
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Re: Template Developers: Please update entries.tpl!

Post by yellowled »

yellowled wrote:If a template contains .tpl files which also loop through said loop (which happens in complex, magazine-style templates), this would have to be assigned in any .tpl file which uses this loop, wouldn't it?
Anyone got some insight on this? Is the assign statement needed anywhere the foreach loop is used or just in the entries.tpl?

YL
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Template Developers: Please update entries.tpl!

Post by garvinhicking »

Hi!
Anyone got some insight on this? Is the assign statement needed anywhere the foreach loop is used or just in the entries.tpl?
Do you have a precise example? If you can simply test it by checking

Code: Select all

<pre>{$entry|@print_r}</pre>
in the files where you re-use $entry, you should see if its assigned or not...?

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Re: Template Developers: Please update entries.tpl!

Post by yellowled »

garvinhicking wrote:Do you have a precise example?
No core template, but some of the more complex, magazine style templates on Spartacus use it e.g. to display articles differently on the start page. I'll test those later today.

YL
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Re: Template Developers: Please update entries.tpl!

Post by yellowled »

https://dl.dropbox.com/u/691134/test-ou ... reused.txt

That's the output of the single entry view using entries_single.tpl in Mimbo, which also uses the foreach loop. Judging from this – Mimbo only has the assign statement in entries.tpl –, I'd say it's working the way it's supposed to. :)

YL
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Re: Template Developers: Please update entries.tpl!

Post by Don Chambers »

Been busy guys. Will definitely need to test this with Kinetic, which I may not get to for a few days.
=Don=
abdussamad
Regular
Posts: 117
Joined: Fri Apr 21, 2006 10:11 pm
Location: Karachi, Pakistan
Contact:

Re: Template Developers: Please update entries.tpl!

Post by abdussamad »

What about the templates on Spartacus? Will those be updated automatically?
Post Reply