how to make index page show latest entry?

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
mork
Posts: 2
Joined: Sun Sep 18, 2005 9:27 am

how to make index page show latest entry?

Post by mork »

I would like my index page to display the latest entry - I have the config option for # of entries to show on start page set to '1', but I'd like for it to display the FULL entry (with comments, comment form, etc).

Anyone have any ideas on how to accomplish this?
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: how to make index page show latest entry?

Post by garvinhicking »

You need to edit your styles "entries.tpl" file. Look for "extended" and you can easily spot the logic that tells whether to display a full entry or a linked one only. :)

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/
mork
Posts: 2
Joined: Sun Sep 18, 2005 9:27 am

Post by mork »

I had looked to the templates initially. I am not able to get what I want that way. Perhaps it is because I am just too unfamiliar with Serendipity's strucutre.

I want not just the full body, but everything - comments (if any) and comment form.

in genpage.inc.php I see this;

Code: Select all

case 'read':
            if (isset($serendipity['GET']['id'])) {
                serendipity_printEntries(array(serendipity_fetchEntry('id', $serendipity['GET']['id'])), 1);
            } 
great! so for the case of read I see what is happening. I can follow through on _printEntries and _fetchEntries and it seems to stand that it should work (and that does). Now, if I try to mimic that a little furtther down in the file;

Code: Select all

        // Welcome screen or whatever
        default:
		if ($serendipity['fetchLimit'] == 1) {
			$serendipity['GET']['id'] = 41;
	                serendipity_printEntries(array(serendipity_fetchEntry('id', $serendipity['GET']['id'])), 1);
		}
		else {
			serendipity_printEntries(serendipity_fetchEntries(null, true, $serendipity['fetchLimit']));
		}
            break;
(added the catch for my situation of fetchLimit being 1) It simply does not work. In this case I'm assigning to ['GET']['id'] a constant. Entry 41 indeed does show up on my main page, but not with comments/comment-form/etc. In reality, I would do a select there or something to fetch the id of the latest non-draft entry.

I've tried a lot of things in this area, and nothing works! I'm really banging my head on my desk at this point as I cannot figure out why! I've put print statements in functions like serendipity_displayCommentForm and it is making it into there, just not displaying the comment form (or comments, or entry navigation).

Scrapping the above idea, I've tried things like this in the _PrintEntries function;

Code: Select all

            /* IF WE ARE DISPLAYING A FULL ENTRY */
            if (isset($serendipity['GET']['id']) || count($entries) == 1) {
Here I've added the condition of there being only 1 entry and to display the full thing. Same results as above, it goes into the functions - I've traced a couple of layers deep into them, but nothing is displayed!

I thought this would be a simple thing.. I'm beginning to wonder if the fight is worth it. Spent a lot of time on this so far. It seems I'm missing something, when I find it - I'm sure I'll slap myself.. but I just don't know what's going on.

Any help would be appreciated.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Mork, you are looking at the wrong place.

You need to do it in the template entries.tpl file as I mentioned, then it's easy:

1. Edit that entries.tpl file. You can find it either in your template directory or in the templates/default/ directory, frmo where you need to copy it into your own template directory.

2. Inside that file I said, look for "extended". You will find this code as first match:

Code: Select all

            {if $entry.is_extended}
            <div class="serendipity_entry_extended"><a id="extended"></a>{$entry.extended}</div>
            {/if}
3. Remove that {if} stuff so that it now reads:

Code: Select all

            <div class="serendipity_entry_extended"><a id="extended"></a>{$entry.extended}</div>
4. Since you now always show the extended part, you can strip the "Read more" link. Do this by removing this block:

Code: Select all

            {if $entry.has_extended and not $is_single_entry and not $entry.is_extended}
            <br /><a href="{$entry.link}#extended">{$CONST.VIEW_EXTENDED_ENTRY|@sprintf:$entry.title}</a><br /><br />
            {/if}
5. You're done. No PHP file editing needed. :-)

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/
Post Reply