With this plugin you can show your items inside a table. The amount of columns is set by the plugin option. The items are shown left to right.
| General Plugin info | |
|---|---|
| Author: | -=Xiffy=- |
| Current Version: | 0.3 |
| Download: | - |
| Code: | code |
| Demo: | - |
| Forum Thread: | here |
Replace this code in the default skin (part Main Index):
<!-- page content --> <div id="container"> <div class="content"> <%blog(default/index,10)%> </div> </div>
With this code:
<!-- page content --> <div id="container"> <div class="content"> <%BlogKolom(default/index,10)%> </div> </div>
Please note that there a changes in your default skin necessary to get a satisfactory appearance of the multi column layout.
Also, in 0.3+ can set the amount as rowXcol. For example, this would show 20 items in a table that with 5 rows and 4 columns:
<!-- page content --> <div id="container"> <div class="content"> <%BlogKolom(default/index,5x4)%> </div> </div>
You can set the category to use if you want, like the blog skin variable:
<!-- page content --> <div id="container"> <div class="content"> <%BlogKolom(default/index,10,Photos)%> </div> </div>
The styling of the table, rows, and cells can be customized by giving class names in the plugin options for each of these elements. Then add css in your skin’s css file to style those classes.
<?php /** * This plugin can be used to insert your blog items or blog items title within a table * History: * v0.1: initial plugin */ class NP_BlogKolom extends NucleusPlugin { var $cols = 2; function getName() { return 'Show in table'; } function getAuthor() { return '-=Xiffy=-'; } function getURL() { return 'http://xiffy.nl/weblog/'; } function getVersion() { return '0.3'; } function getDescription() { return 'Call this instead of <%blog()%> to show your items side by side in a table by using <%BlogKolom%>.'; } function install() { // create some options $this->createOption('Cols','Default cols','text','2'); $this->createOption('tabledivName','DIV name used for the table (for css class)','text',''); $this->createOption('tableRowdivName','DIV name used for <tr> (for css class)','text',''); $this->createOption('tableCelldivName','DIV name used for <td> (for css class)','text',''); } function init() { $cols = intval($this->getOption('Cols')); if (!$cols) $cols = 2; $this->cols = $cols; } function doSkinVar($skinType, $template, $amount = 10, $category = '') { global $manager, $blog, $CONF; //$cols = $this->getOption(Cols); //$tableDiv = $this->getOption('tableDivname'); $amount = strtolower(str_replace(' ','',$amount)); if (strpos($amount,'x') === false) { if (intval($amount) < 1 ) $amount = 10; else $amount = intval($amount); } else { list($rows,$columns) = explode('x',$amount); $rows = intval($rows); $columns = intval($columns); $amount = $rows * $columns; if ($columns) $this->cols = $columns; if (intval($amount) < 1 ) $amount = 10; else $amount = intval($amount); } $this->readLog($template, $amount, $category); } /* just adding params; What I really don't like about this implementation is the vast amount of code that has been reproduced overhere that really belomgs in BLOG.php, not here Why? Cause there is no way to get between ReadLog and ShowUsingQuery. The calls just keep on going, never returning an object. Adding params and run forward. All I wanted was to change showUsingQuery. */ function readLog($template, $amountEntries, $category) { $this->readLogAmount($template,$amountEntries,"","",1,1,$category); } function readLogAmount($template, $amountEntries, $extraQuery, $highlight, $comments, $dateheads, $category) { global $manager, $blog, $CONF, $HTTP_COOKIE_VARS; if ($blogName) { $b =& $manager->getBlog(getBlogIDFromName($params[2])); } else if ($blog) { $b =& $blog; } else { $b =& $manager->getBlog($CONF['DefaultBlog']); } $this->_setBlogCategory($b, $category); $query = 'SELECT i.inumber as itemid, i.ititle as title, i.ibody as body, m.mname as author, m.mrealname as authorname, UNIX_TIMESTAMP(i.itime) as timestamp, i.imore as more, m.mnumber as authorid, c.cname as category, i.icat as catid, i.iclosed as closed' . ' FROM nucleus_item as i, nucleus_member as m, nucleus_category as c' . ' WHERE i.iblog='.$b->blogid . ' and i.iauthor=m.mnumber' . ' and i.icat=c.catid' . ' and i.idraft=0' // exclude drafts // don't show future items . ' and i.itime<=' . mysqldate($b->getCorrectTime()); if ($b->getSelectedCategory()) $query .= ' and i.icat=' . $b->getSelectedCategory(); $query .= $extraQuery . ' ORDER BY i.itime DESC'; if ($amountEntries > 0) $query .= ' LIMIT ' . $amountEntries; return $this->showUsingQuery($template, $query, $highlight, $comments, $dateheads); } function showUsingQuery($template, $query, $highlight = '', $comments = 0, $dateheads = 1) { global $manager, $blog, $CONF, $HTTP_COOKIE_VARS; if ($blogName) { $b =& $manager->getBlog(getBlogIDFromName($params[2])); } else if ($blog) { $b =& $blog; } else { $b =& $manager->getBlog($CONF['DefaultBlog']); } $lastVisit = cookieVar('lastVisit'); if ($lastVisit != 0) $lastVisit = $b->getCorrectTime($lastVisit); $template = TEMPLATE::read($template); // create parser object & action handler $actions = new ITEMACTIONS($b); $parser = new PARSER($actions->getDefinedActions(),$actions); $actions->setTemplate($template); $actions->setHighlight($highlight); $actions->setLastVisit($lastVisit); $actions->setParser($parser); $actions->setShowComments($comments); // execute query $items = sql_query($query); $rowCount = (float) 0; $currentDiv = $this->getOption('tabledivName'); $cols = $this->cols; /* How many columns to use */ echo "<table class='$currentDiv'>"; // loop over all items while ($item = mysql_fetch_object($items)) { // action handler needs to know the item we're handling $actions->setCurrentItem($item); if (($rowCount % $cols) == 0 ) { if ($rowCount >= $cols) { echo '</tr>'; } $currentDiv = $this->getOption('tableRowdivName'); echo "<tr class='$currentDiv'>"; } $rowCount = $rowCount + 1; $currentDiv = $this->getOption('tableCelldivName'); echo "<td class='$currentDiv'>"; // add date header if needed if ($dateheads) { $new_date = date('dFY',$item->timestamp); if ($new_date != $old_date) { // unless this is the first time, write date footer $timestamp = $item->timestamp; if ($old_date != 0) { $manager->notify('PreDateFoot',array('blog' => &$b, 'timestamp' => strtotime($old_date))); $parser->parse($template['DATE_FOOTER']); $manager->notify('PostDateFoot',array('blog' => &$b, 'timestamp' => strtotime($old_date))); } $manager->notify('PreDateHead',array('blog' => &$b, 'timestamp' => $timestamp)); // note, to use templatvars in the dateheader, the %-characters need to be doubled in // order to be preserved by strftime $parser->parse(strftime($template['DATE_HEADER'],$timestamp)); $manager->notify('PostDateHead',array('blog' => &$b, 'timestamp' => $timestamp)); } $old_date = $new_date; } // parse item $parser->parse($template['ITEM_HEADER']); $manager->notify('PreItem', array('blog' => &$b, 'item' => &$item)); $parser->parse($template['ITEM']); $manager->notify('PostItem', array('blog' => &$b, 'item' => &$item)); $parser->parse($template['ITEM_FOOTER']); // and close this tag echo '</td>'; } $numrows = mysql_num_rows($items); // add another date footer if there was at least one item if (($numrows > 0) && $dateheads) { $manager->notify('PreDateFoot',array('blog' => &$b, 'timestamp' => strtotime($old_date))); $parser->parse($template['DATE_FOOTER']); $manager->notify('PostDateFoot',array('blog' => &$b, 'timestamp' => strtotime($old_date))); } echo '</tr></table>'; mysql_free_result($items); // free memory return $numrows; } function _setBlogCategory(&$blog, $catname) { global $catid; if ($catname != '') $blog->setSelectedCategoryByName($catname); else $blog->setSelectedCategory($catid); } } ?>
NP_BlogKolom version 0.1 works with Nucleus CMS version 3.31 - 2007-10-30 kg