Can I change the variables used in entries.tpl {foreach}

Skinning and designing Serendipity (CSS, HTML, Smarty)
Post Reply
carl_galloway
Regular
Posts: 1331
Joined: Sun Dec 04, 2005 5:43 pm
Location: Andalucia, Spain
Contact:

Can I change the variables used in entries.tpl {foreach}

Post by carl_galloway »

Hi all,

I'm trying to change the {foreach} loop in entries.tpl so that the first entry is ignored. The code below works well for sticky entries and where only a single entry was written on the day, but if more than one entry was written on the day then all entries for that day are ignored.

Code: Select all

{foreach name="entryloop" from=$entries
item="dategroup"}
{foreach from=$dategroup.entries item="entry"}
{if $smarty.foreach.entryloop.index==0 }
<!-- don't print -->
{else}
How would I separate out only the first entry? I've tried changing item="dategroup" to item="entry". I've also tried adding a {counter} between the foreach loops, but nothing seems to work.

Thanks, Carl
mgroeninger
Regular
Posts: 546
Joined: Mon Dec 20, 2004 11:57 pm
Contact:

Re: Can I change the variables used in entries.tpl {foreach}

Post by mgroeninger »

Ok, I am guessing here, but wouldn't this work:

Code: Select all

{foreach name="loop1"  from=$entries
item="dategroup"}
{foreach name="loop2" from=$dategroup.entries item="entry"}
{if $smarty.foreach.loop1.index==0 && $smarty.foreach.loop2.index==0}
<!-- don't print -->
{else}

My logic is this: You want to exclude the first post, but include all the other posts regardless of date?

So, I think you want to loop through the dates, calling the loop "loop1".

Then you loop through the entries, but let's call this something else so we don't get confused, like "loop2".

Then we just ignore the first index result from loop2, but only if we are still in loop1 first index.
carl_galloway
Regular
Posts: 1331
Joined: Sun Dec 04, 2005 5:43 pm
Location: Andalucia, Spain
Contact:

Post by carl_galloway »

Oh Matthew, you can have my first born for that, works a treat - thank you.
mgroeninger
Regular
Posts: 546
Joined: Mon Dec 20, 2004 11:57 pm
Contact:

Post by mgroeninger »

*grin* I'm glad it worked, but you can keep your first born... Mine's enough to run me ragged; I'm trying not to collect anyone elses... :D
Post Reply