Hello!
I just thought about being able to have a text, a banner, etc. appear only 1 time (or 3
times, or 4 times as configured) on a page.
For example:
You'll have AdSense on your overview pages, where you show 10 entries. You want
to a horizontal AdSense Block under each entry's summary. But you must not
show more than 3 of those blocks on a page.
One can test a numerical variable in the Smarty template that counts the
number of entries on the current page. Then include or not include the text.
But how and where would I set up this variable?
Is there such a variable already?
Yours
John
[solved] Counter for entries in entries.tpl needed?
-
- Regular
- Posts: 116
- Joined: Mon Aug 20, 2007 4:00 am
- Location: Spain
- Contact:
[solved] Counter for entries in entries.tpl needed?
Last edited by johncanary on Thu Jun 12, 2008 6:59 pm, edited 1 time in total.
Yours John
: John's Google+ Profile
: John's E-Biz Booster Blog powered by Serendipity 1.7/PHP 5.3.14
: John's Google+ Profile
: John's E-Biz Booster Blog powered by Serendipity 1.7/PHP 5.3.14
-
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: Counter for entries in entries.tpl needed?
Hi!
Check the smarty {counter} function in the smarty function docs?
HTH,
Garvin
Check the smarty {counter} function in the smarty function docs?
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/
-
- Regular
- Posts: 3652
- Joined: Mon Feb 13, 2006 2:40 am
- Location: Chicago, IL, USA
- Contact:
John - check out Carl's Affiliate template - I think he is doing something like that.... perhaps not exactly what you are requested, but his code might reveal a method you can adapt.
http://www.carlgalloway.com/pages/seren ... lates.html
http://www.carlgalloway.com/pages/seren ... lates.html
=Don=
-
- Regular
- Posts: 116
- Joined: Mon Aug 20, 2007 4:00 am
- Location: Spain
- Contact:
Thanks for your prompt replies. Sounds promising.
I'll check it out and will give you feedback.
I'll check it out and will give you feedback.
Yours John
: John's Google+ Profile
: John's E-Biz Booster Blog powered by Serendipity 1.7/PHP 5.3.14
: John's Google+ Profile
: John's E-Biz Booster Blog powered by Serendipity 1.7/PHP 5.3.14
-
- Regular
- Posts: 116
- Joined: Mon Aug 20, 2007 4:00 am
- Location: Spain
- Contact:
Thanks
Thanks for the tips. I am confident that I can figure it out based on that info.
It's just not of any high priority right now.
John
It's just not of any high priority right now.
John
Yours John
: John's Google+ Profile
: John's E-Biz Booster Blog powered by Serendipity 1.7/PHP 5.3.14
: John's Google+ Profile
: John's E-Biz Booster Blog powered by Serendipity 1.7/PHP 5.3.14
-
- Regular
- Posts: 116
- Joined: Mon Aug 20, 2007 4:00 am
- Location: Spain
- Contact:
Solution
I finally found dealt with this one. Thanks to your tips, it was quite easy.
I used the Smarty Custom Function {counter}
For those, who want to hardcode their templates, too:This code will show the add on all multientry pages (like the home page, categories, ...) on top of the 2nd entry.
I used the Smarty Custom Function {counter}
For those, who want to hardcode their templates, too:
Code: Select all
# entries.tpl
##############
...
{foreach from=$entries item="dategroup"}
<div class="serendipity_Entry_Date">
{foreach from=$dategroup.entries item="entry"}
{counter name="entry_number" print=0 assign=entry_number}
{if $entry_number == 2}
{* AD HTML Code Start: shown at top of the second entry! *}
<div>
<a href="http://aff.example.com/?id=23">
<img src="http://aff.example.com/i/b45.jpg" alt=""
width="468" height="60" />
</a>
</div>
{* AD HTML Code End *}
{/if}
<h4 class="serendipity_title"><a href="{$entry.link}">{$entry.title}</a></h4>
<h3 class="serendipity_date">
...
Yours John
: John's Google+ Profile
: John's E-Biz Booster Blog powered by Serendipity 1.7/PHP 5.3.14
: John's Google+ Profile
: John's E-Biz Booster Blog powered by Serendipity 1.7/PHP 5.3.14