Limitation of wbtoc() in DCWD templates

About the template and stylesheet - and changing the menu
Post Reply
beate_r
Posts: 174
Joined: Thu May 22, 2008 11:44 pm
Location: Hessen / Germany

Limitation of wbtoc() in DCWD templates

Post by beate_r » Sat Dec 27, 2008 4:36 pm

Hi everyone,

some of the recent versions of Mikey's templates implement Jens Broechers wbtoc() navigation system. Not the worst idea, but sometimes the hard coded length of 20 characters hurts.

Here a small enhancement to make this configurable. I replaced the hard coded size by a global variable $wbtocl, which defaults to 20 and can easily be set in config.php.

Setting it to a very large value effectively disables the length limit, and at least the roundabout2 template works very well with such a setting ;)

To enable, simply replace the following function in template.htm (which is less effort than adapting templates like roundabout2 to the normal toc function):

Code: Select all

function aWithClass($i, $x, $clsname)                                           
 {                                                                              
    global $sn, $u, $wbtocl;                                                    
        $elip = $x;                                                             
        $title = '';                                                            
        if( !$wbtocl ) $wbtocl=20;                                              
        if ( (strpos( $x, 'link:'  ) === false ) && (strpos( $x, 'link_blank:' \
 ) === false ) )                                                                
    {                                                                           
           if (strlen($x) > $wbtocl+1) {                                        
             $elip = substr($x,0,$wbtocl) . '...';                              
             $title = ' Title = "'. $x  .'"';                                   
           }                                                                    
        return '<a  class="'.  $clsname.'" href="' . $sn . '?' . $u[$i].'" ' . \
$title . '>' .$elip. '</a>' ;                                                   
        }                                                                       
        else                                                                    
        {                                                                       
             list ($item,$url)= split('@',$x);                                  
                 if (strpos( $x, 'link_blank:'  ) === false )                   
         {                                                                      
                    $item =  str_replace('link:','',$item);                     
                if (strlen($item) > $wbtocl+1) {                                
                  $title = ' Title = "'. $item  .'"';                           
                  $item = substr($item,0,$wbtocl) . '...';                      
                                                                                
                }                                                               
                return '<a class="'.  $clsname.'" href="' . $url. '" ' . $title\
 . '>' .$item. '</a>' ;                                                         
                 }                                                              
                 else                                                           
                 {                                                              
                   $item =  str_replace('link_blank:','',$item);                
               if (strlen($item) > $wbtocl+1) {                                 
                 $title = ' Title = "'. $item  .'"';                            
                 $item = substr($item,0,$wbtocl) . '...';                       
                                                                                
               }                                                                
               return '<a  class="'. $clsname.'" href="' . $url. '" ' . $title \
. ' target="_" >' .$item. '</a>' ;                                              
                 }                                                              
        }                                                                       
                                                                                
} 
Beate

Post Reply