Add code only after first entry (how?)

Skinning and designing Serendipity (CSS, HTML, Smarty)
Post Reply
frenzis
Posts: 2
Joined: Tue Mar 09, 2010 1:33 pm

Add code only after first entry (how?)

Post by frenzis »

I think this is pretty simple (but not for me ;) )

I need to add a custom code just after the first entry in the blog homepage (not the first entry of every page).

Like this

POST1
[custom code]
----------------------
POST2
----------------------
POST3
----------------------
---page2----
POST1
[NOT CUSTOM CODE]
----------------------
POST2
----------------------
POST3

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

Re: Add code only after first entry (how?)

Post by garvinhicking »

# 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/
frenzis
Posts: 2
Joined: Tue Mar 09, 2010 1:33 pm

Re: Add code only after first entry (how?)

Post by frenzis »

Thank you, this works with a little correction.
Do you think is correct?

NOT WORKING

Code: Select all

{foreach from=$entries item="dategroup" name="outerloop"}
   {foreach from=$dategroup.entries item="entry" name="innerloop"}
   
    {if $startpage && $smarty.innerloop.first && $smarty.outerloop.first}
    <div class="first">
    {else}
    <div>
    {/if}

    ....

   {/foreach}
{/foreach}
WORKING

Code: Select all

{foreach from=$entries item="dategroup" name="outerloop"}
   {foreach from=$dategroup.entries item="entry" name="innerloop"}
   
    {if $startpage && $smarty.foreach.innerloop.first && $smarty.foreach.outerloop.first}
    <div class="first">
    {else}
    <div>
    {/if}

    ....

   {/foreach}
{/foreach}
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Add code only after first entry (how?)

Post by garvinhicking »

Hi!

Good catch! Yes, that would be the proper notation!

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/
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Re: Add code only after first entry (how?)

Post by Don Chambers »

Yes, your revision looks correct.
=Don=
Post Reply