Page 1 of 2

Template Developers: Please update entries.tpl!

Posted: Mon Jan 21, 2013 9:42 am
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.

Re: Template Developers: Please update entries.tpl!

Posted: Mon Jan 21, 2013 10:37 am
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.

Re: Template Developers: Please update entries.tpl!

Posted: Mon Jan 21, 2013 12:58 pm
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

Re: Template Developers: Please update entries.tpl!

Posted: Mon Jan 21, 2013 2:09 pm
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

Re: Template Developers: Please update entries.tpl!

Posted: Mon Jan 21, 2013 2:27 pm
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.

Re: Template Developers: Please update entries.tpl!

Posted: Mon Jan 21, 2013 4:19 pm
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

Re: Template Developers: Please update entries.tpl!

Posted: Mon Jan 21, 2013 6:40 pm
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

Re: Template Developers: Please update entries.tpl!

Posted: Mon Jan 21, 2013 6:55 pm
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

Re: Template Developers: Please update entries.tpl!

Posted: Mon Jan 21, 2013 7:46 pm
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

Re: Template Developers: Please update entries.tpl!

Posted: Mon Jan 21, 2013 7:47 pm
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

Re: Template Developers: Please update entries.tpl!

Posted: Tue Jan 22, 2013 9:47 am
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

Re: Template Developers: Please update entries.tpl!

Posted: Tue Jan 22, 2013 10:51 am
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

Re: Template Developers: Please update entries.tpl!

Posted: Tue Jan 22, 2013 11:11 am
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

Re: Template Developers: Please update entries.tpl!

Posted: Tue Jan 22, 2013 9:43 pm
by Don Chambers
Been busy guys. Will definitely need to test this with Kinetic, which I may not get to for a few days.

Re: Template Developers: Please update entries.tpl!

Posted: Tue Feb 26, 2013 1:54 am
by abdussamad
What about the templates on Spartacus? Will those be updated automatically?