Hi,
I am trying to emit out a google ad only on the last entry on the page.
I am trying to use the code as follows:
{if $smarty.foreach.dategroup.last}
.... Place google-adsense-code ....
{/if}
However, I am getting ad on all the entries.
Am I doing something wrong?
Cheers,
Gaurav
Not directly S9Y... but probably Smarty
-
mastergaurav
- Regular
- Posts: 16
- Joined: Wed Oct 04, 2006 6:46 pm
-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: Not directly S9Y... but probably Smarty
Hi!
I think you are looking on the wrong, inner smarty foreach loop. There are two nested loops, you need to check the outer one, because the inner one would return "last" multiple times.
The outer loop is for all entries of the page, the inner loop for all entries of a single date on the page.
HTH,
Garvin
I think you are looking on the wrong, inner smarty foreach loop. There are two nested loops, you need to check the outer one, because the inner one would return "last" multiple times.
The outer loop is for all entries of the page, the inner loop for all entries of a single date on the page.
HTH,
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/
# 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/
-
mastergaurav
- Regular
- Posts: 16
- Joined: Wed Oct 04, 2006 6:46 pm
Re: Not directly S9Y... but probably Smarty
I had it on the outer loop:garvinhicking wrote:I think you are looking on the wrong, inner smarty foreach loop.
{foreach from=$entries item="dategroup"}
<div class="serendipity_Entry_Date">
{if $dategroup.is_sticky}
<h3 class="serendipity_date">{$CONST.STICKY_POSTINGS}</h3>
{else}
<h3 class="serendipity_date">{$dategroup.date|@formatTime:DATE_FORMAT_ENTRY}</h3>
{/if}
{if $smarty.foreach.dategroup.first}
<!-- ADSENSE CODE HERE -->
{/if}
.........
.........
{foreach ......}
.........
.........
{/foreach}
.........
.........
{/foreach}
Cheers,
Gaurav
-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: Not directly S9Y... but probably Smarty
Hi!
You must assign a name to the loop!
HTH,
Garvin
You must assign a name to the loop!
Code: Select all
{foreach name="outerloop" from=$entries item="dategroup"}
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/
# 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/
-
mastergaurav
- Regular
- Posts: 16
- Joined: Wed Oct 04, 2006 6:46 pm
Re: Not directly S9Y... but probably Smarty
You must assign a name to the loop!
Hi Garvin,
Thanks! It just works beautifully. I think I am learning Smarty pretty fast
Cheers,
Gaurav Vaish
http://www.mastergaurav.com
http://eduzine.edujinionline.com