way to show latest posts (not home page display)

Started by kennethmgreen, April 09, 2006, 11:22:46 PM

Previous topic - Next topic

kennethmgreen

I'm looking for a way to display the latest posts - other than the home page option.

I've seen the mod for Latest Post Mambo Module but I'm not using Mambo. This appears to be the only mod of this kind.

What I'm trying to do is provide a way for users to click a link and see all the latest posts - similar in functionality to the "Number of recent posts to display on board index:" setting (Current Theme Settings), but on it's own page.

I'd like to remove the latest posts from the board index if possible and just have a link for "latest posts" that would display a (configurable) list of most recent messages in a new page. Is this possible? I've looked around the index template, but didn't see anything for the recent posts.

I can probably dig around the files for the theme I'm using (Classic), but if anyone has any suggestions, or has done/knows of this solution, please let me know.

Thanks.

Using SMF 1.0.7.

kennethmgreen

Actually, maybe a better question is how to modify the number of posts shown in: /index.php?action=recent

When I click the document icon in the Recent Posts lists on index, I am taken to [forum URL]/index.php?action=recent which shows the last 10 posts. Where does that number get set?

I have the theme setting at 20 (so the 20 most recent posts are shown on the index page). If I could modify the number of posts shown for /index.php?action=recent, this would be all I'd need.

kennethmgreen

Ah-ha! Found my own answer...

In /Sources/Recent.php look for function RecentPosts() around line 131.

All I needed to do was change the LIMIT value in the SQL statement. There are two places to do this:

Look for the sections commented:
   // Find the 10 most recent messages they can *view*.
and:
   // Get all the most recent posts.

Modify the LIMIT line in the SQL statement.

I changed it to 50 in both places and now, when I click the document icon (going to /index.php?action=recent), the last 50 posts are shown.

This is working, but if I've forgotten something or gone about it wrong, please correct me.

kennethmgreen

Thanks redone, for moving this to a more appropriate place.

Looking at the code some more in Recent.php, I have some questions. (I'm using SMF 1.0.7 in case that makes a difference)

function getLastPost() uses ORDER BY b.lastUpdated DESC to get very latest post. LIMIT is set to 1.

function getLastPosts($showlatestcount) uses ORDER BY m.ID_MSG DESC and LIMIT is set to $showlatestcount.

It looks like getLastPosts($showlatestcount) is for theme-specific displays (ex: BoardIndex.template.php in /Themes/classic) and only affects the board index page.

So, am I correct in modifying the LIMIT values RecentPosts() in /Sources/Recent.php in order to change the number of posts displayed in /index.php?action=recent ? And if so, should that be an administrative option?

I just want to make sure I'm going about this the right way. I also think that this would be a valuable option for others. I had users specifically request this feature. It would be cool to have the recent posts page paginate - allow admins to set high LIMIT values (500 or more, for example) and show NN message per page.

Another question about function RecentPosts()

Can someone explain what's going on with the two different SQL calls? (the two $request = db_query queries)

The first query is commented: // Find the 10 most recent messages they can *view*.

The second query is commented: // Get all the most recent posts.

Why do both queries have LIMIT values?


Finally, and this is just a suggestion.. I think using $txt[214] for both the title of recent posts on the index *AND* the title of the Recent Posts page (/index.php?action=recent) isn't a good idea. Recent Page is titled here:

/Sources/Recent.php [~line 145]

   loadTemplate('Recent');
   $context['page_title'] = $txt[214];


Since the recent page and index list of recent posts are really two different pieces of information, they should have their own title. The Recent Posts page is affected by RecentPosts() and the LIMIT setting, whereas the index list of latest posts in part of the theme.

I discovered this when trying to add a helpful hint for users. I set $txt[214] = "Recent Posts - (click document icon at left for longer list)" This looked fine on the index page, but looked a bit strange when a user clicked the icon and the title of the page was the same thing.

My fix was to modify Themes/classic/BoardIndex.template.php [line 181] to:
      <td class="catbg" colspan="2">', $txt[214], ' - (click document icon at left for longer list)</td>

But I hate having to hard code stuff when I don't have to.

Anyway, thank for any help/guidance/advice you can provide. Your hard work on SMF is surely appreciated. SMF is so much better than the other forums I've worked with. My gracious thanks to all the coders that take the time to insert easy-to-understand comments in the code.

Advertisement: