Page 1 of 1

Add code only after first entry (how?)

Posted: Tue Mar 09, 2010 1:37 pm
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.

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

Posted: Tue Mar 09, 2010 2:34 pm
by garvinhicking

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

Posted: Tue Mar 09, 2010 3:13 pm
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}

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

Posted: Tue Mar 09, 2010 3:39 pm
by garvinhicking
Hi!

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

Regards,
Garvin

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

Posted: Tue Mar 09, 2010 3:49 pm
by Don Chambers
Yes, your revision looks correct.