The rss_aggregation is a nice feature but I like to have the beginning of the articles from one feed on the same page. For example:
Wasn't he just in the tape safe? Episode 33 It's a quiet afternoon in Mission Control when I'm woken from my slumber by a dull banging noise coming…
Percussive maintenance Episode 32 “WOAH THERE, Crash Gordon!” the PFY shouts as our engineer prepares to put our system back together “How's about …
Very few modifications are needed to have this behavior in DokuWiki
The whole description maybe sometimes too much. It will then be truncated. An example function found on php.net does the trick, even adding ellipsis ! It is added as a method of
Doku_Renderer_xhtml
:
/** * Truncate a string to the specified number of characters, adding ellipsis * * @author http://www.php.net/substr_replace */ function truncate($substring, $max = 50, $rep = '...') { if(strlen($substring) < 1){ $string = $rep; }else{ $string = $substring; } $leave = $max - strlen ($rep); if(strlen($string) > $max){ return substr_replace($string, $rep, $leave); }else{ return $string; } }
We can then use it to display a truncated description for every article:
function rss ($url){ (...) $i=0; foreach ($rss->items as $item ) { $this->doc .= '<li>'; $this->externallink($item['link'],$item['title']); $this->doc .= '<br /><span class="rss_description">' . $this->truncate(strip_tags($item['description']),150); $this->doc .= '</span></li>'; if($i++>=4) break; } (...) }
Note the $i
variable which ensures that no more than 5 headlines are displayed.
— Olivier Mehani 2005-12-03 01:00