It's better when it's simple

User Tools

Site Tools


Descriptions in RSS aggregator

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 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
     function truncate($substring, $max = 50, $rep = '...') {
             if(strlen($substring) < 1){
                     $string = $rep;
                     $string = $substring;
             $leave = $max - strlen ($rep);
             if(strlen($string) > $max){
                     return substr_replace($string, $rep, $leave);
                     return $string;

We can then use it to display a truncated description for every article:

     function rss ($url){
            foreach ($rss->items as $item ) {
                $this->doc .= '<li>';
                $this->doc .= '<br /><span class="rss_description">' .
                $this->doc .= '</span></li>';

Note the $i variable which ensures that no more than 5 headlines are displayed.

Olivier Mehani 2005-12-03 01:00

tips/rss_description.txt · Last modified: 2008-08-10 15:28 by chi

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki