entries.tpl - ouput element only on first entry?

Skinning and designing Serendipity (CSS, HTML, Smarty)
Post Reply
Dawn
Regular
Posts: 69
Joined: Thu May 04, 2006 11:46 am

entries.tpl - ouput element only on first entry?

Post by Dawn »

Hi,

I just wanted to know if anybody here know how can I ouput en element for the blog (like a custom string, an ad or something else) only on the first blog entry?

Example:
-----------
bla
Entry 1
-----------
-----------
Entry 2
-----------
-----------
Entry 3
-----------

I know I've to edit entries.tpl for that purpose, but I couldn't find out how can I display it only for the first (or for example for the first 3 entries). Is there a way how I can do that? Is there an abstract about entry.[property]?

Help would be nice...

Greets and best regards,
Dawn
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: entries.tpl - ouput element only on first entry?

Post by garvinhicking »

Hi!

As you found out, you can edit the entries.tpl template, but you would need to check specific $smarty.foreach.XXX variable to check if the current loop index is "1" or not. This forums holds at least 2 threads I think where this is discussed, maybe you can search for "smarty foreach first" or something like that.

The other way would be to use the plugin "Include/Show entry blocks" where you can define specific ad-blocks or something else to show up every Xth entry in your blog.

Best 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/
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post by judebert »

I like using {counter} for this. Use its "assign" attribute and an {if} statement for checking.
Judebert
---
Website | Wishlist | PayPal
Dawn
Regular
Posts: 69
Joined: Thu May 04, 2006 11:46 am

Post by Dawn »

Hi Garvin and Judebert,

Thanks for your answers. I decided to take Judeberts solution for my "problem". For others which are searching for a solution, here some sample code:

On the firstline (or in any cache before the foreach of entries.tpl) I've added the following code:

Code: Select all

{counter print=false assign=entry_counter}
Then on the place I want my custom output depending on the entry-number I've added this code:

Code: Select all

{if $entry_counter == 1}
hello world<br>
{/if}
{counter}
Now I've got a last wish: Which file and where in it do I have to edit to display custom output AFTER the output of the plugin(s) (in my case for example the serendipity_event_findmore plugin).

Greets and best regards,
Dawn
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi Dawn!

Great you got that to work!
Now I've got a last wish: Which file and where in it do I have to edit to display custom output AFTER the output of the plugin(s) (in my case for example the serendipity_event_findmore plugin).
Look in the entries.tpl file for "{$entry.add_footer}", that holds stuff added by event plugins.

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/
Dawn
Regular
Posts: 69
Joined: Thu May 04, 2006 11:46 am

Post by Dawn »

Hi Garvin,

Thanks for your answer :) I tried to edit entires.tpl after "{$entry.add_footer}" as you described it. It's true that there are some plugins loaded like Tags an so on.. But do you know if the plugin serendipity_event_findmore is loaded at a special place?

For example if I edit entries.tpl right after "{$entry.add_footer}" it ouputs my custom output in the box on my blog. But serendipity_event_findmore is loaded at the end of the entry (and non extended entry). Do you have an idea what I can do? If you don't know what I mean take a look at http://blog.blankster.info.

Greets and best regards,
Dawn
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Ah, I'm sorry. In fact the social bookmarks plugin uses {$entry.plugin_display_dat} to store its output into.

In cases like this it helps for you to simple add stuff like "<!--test1-->" into the various places in entries.tpl to see where this is placed in the output HTML.

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/
Dawn
Regular
Posts: 69
Joined: Thu May 04, 2006 11:46 am

Post by Dawn »

Thanks for your help garmin, that worked. And thanks for the hint... I've allready tried to test where there right place is (I've found "{$entry.add_footer}" during my tests too) but I couldn't find it and tought perhaps anybody here knowswhere the right place is.

Greets and a very nice weekend,
Dawn
Post Reply