Loading...
 
Skip to main content

Features / Usability


Show Title of Last Post in Blog List

posts: 2

Hi everyone,
I am quite new to TikiWiki and have a question concerning the Blog List Template (tiki-list_blogs.tpl).

I want to show the title of the last Post of the respective Blog in the Blog List. Is there any way to do this?
Maybe there is a function providing this feature like .lastModif is capable of showing the last time a post was posted in a blog.

Any help would be appreciated. Thanks.
Clemens

posts: 113 Ireland

You will need to modify tiki-list_blogs.php as well as tiki-list_blogs.tpl. You need the title of the blog, and that is not in any existing smarty variable. There are two ways (that I can see) that gets the variable from a function:

A) If you look at modules/mod-last_blog_posts.php you can see how to get the last blog ($tikilib->list_posts).
B) If you look at tiki-list_blog_posts.php you can see how to get last blog ($bloglib->list_blog_posts).

Set the blogId appropriately, set the maxRecords = 1, and sortmode is created_desc.

You need to add that to the tiki-list_blogs.php so that the smarty variable is assigned. Then you need to modify the tpl file to display it as desired.

gary

posts: 2

Hey Gary,
thanks alot for your help.

I managed to integrate it for one Blog. What I did not get it to do however is this function for more blogs. Instead of showing each last post title from the respective blog I get last posts title no matter from which blog in the table.

So my problem is the BlogId. How can I link the BlogId to the BlogId of the last post.

In the loop section in the template I added {$listpostschanges.title} with $listposts as the smarty tag for $tikilib->list_posts.

In my php file I added:
$listposts = $tikilib->list_posts($offset = 0, $maxRecords = -1, $sort_mode = 'created_desc', $find = '', $filterByBlogId = -1);
$smarty->assign('listposts', $listposts%22data%22);

I am sorry to ask again but I really am new to this. Thanks.
Clemens


posts: 113 Ireland

set the $filterByBlogId to the ))BlogId(( of interest. So the calling sequence should be

Copy to clipboard
$offset = 0; $maxRecords = 1; $sort_mode = 'created_desc'; $find = ''; $filterBlogId = BlogId; $listposts = $tikilib->list_posts($offset, $maxRecords, $sort_mode, $find, $filterByBlogId);



gary