Lade...
 
Skip to main content

ListBlogPosts

Q: How can I get a list of blog posts of my Blog (blogId=1) in a wiki page?
A: Use this in a wiki page:

(will be introduced with tiki 1.9.1)

Copy to clipboard
{MODULE(module=>last_blog_posts,blogid=>1)}{MODULE}



modify lib/tikilib.php:

Copy to clipboard
/*shared*/ function list_posts($offset = 0, $maxRecords = -1, $sort_mode = 'created_desc', $find = '', $filterByBlogId = -1) { if ($filterByBlogId >= 0) { // get posts for a give blogId: $mid = " where ( `blogId` = ? ) "; $bindvars = array($filterByBlogId); } else { // get posts from all blogs $mid = ''; $bindvars = array(); } if ($find) { $findesc = '%' . $find . '%'; if ($mid == "") { $mid = " where "; } else { $mid .= " and "; } $mid .= " ( `data` like ? ) "; $bindvars[] = $findesc; } $query = "select * from `tiki_blog_posts` $mid order by ".$this->convert_sortmode($sort_mode); $query_cant = "select count(*) from `tiki_blog_posts` $mid"; $result = $this->query($query,$bindvars,$maxRecords,$offset); $cant = $this->getOne($query_cant,$bindvars); $ret = array(); while ($res = $result->fetchRow()) { $blogId = $res["blogId"]; $query = "select `title` from `tiki_blogs` where `blogId`=?"; $cant_com = $this->getOne("select count(*) from `tiki_comments` where `object`=? and `objectType` = ?", array((string) $res["postId"],'blog')); $res["comments"] = $cant_com; $res["blogTitle"] = $this->getOne($query,array((int)$blogId)); $res["size"] = strlen($res["data"]); $ret[] = $res; } $retval = array(); $retval["data"] = $ret; $retval["cant"] = $cant; return $retval; }


Modify one line in module modules/mod-last_blog_posts.php

Copy to clipboard
$ranking = $tikilib->list_posts(0, $module_rows, 'created_desc', '', (isset($module_params["blogid"]) ? $module_params["blogid"] : -1 ) );


Zu dieser Seite haben beigesteuert: ohertel .
Seite zuletzt geändert: am 20.05.05 23:29 von ohertel.