[ PHPXref.com ] [ Generated: Sun Jul 20 16:35:25 2008 ] [ bBlog 0.7.6 ]
[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/bblog/bBlog_plugins/ -> function.sectionlinks.php (source)

   1  <?php
   2  function identify_function_sectionlinks () {
   3  $help = '
   4  <p>Sectionlinks is a Smarty function to be used in templates.
   5  <p>Example usage
   6  <ul><li>To create a link list of sections, one per line :<br>
   7     {sectionlinks}
   8     <li>To create a link list of sections, seperated by a # <br>
   9       {sectionlinks sep="#"}
  10       <li>To make a list with &lt;ul&gt use {sectionlinkd mode="list"}<br />
  11     <li>Used within a {posts} loop, to link to sections that the post is in, seperated by a commer :<br>
  12        {sectionlinks sep=", " sections=$post.sections}
  13  </ul>';
  14  
  15  
  16    return array (
  17      'name'           =>'sectionlinks',
  18      'type'             =>'function',
  19      'nicename'     =>'Section Links',
  20      'description'   =>'Make links to sections',
  21      'authors'        =>'Eaden McKee <eadz@bblog.com>',
  22      'licence'         =>'GPL',
  23      'help'   => $help
  24    );
  25  
  26  
  27  }
  28  
  29  function smarty_function_sectionlinks($params, &$bBlog) {
  30  
  31      $linkcode = '';
  32  
  33      if(!isset($params['mode'])) $mode = "break";
  34      else $mode = $params['mode'];
  35  
  36      if($mode=='list') $sep = "";
  37      else if(!isset($params['sep'])) $sep = "<br />";
  38      else $sep = $params['sep'];
  39  
  40      if(isset($params['sections'])) $sections = $params['sections'];
  41      else $sections = $bBlog->sections;
  42  
  43      $num = count($sections);
  44      $i=0;
  45    
  46      if ($mode=='list') $linkcode .= "<ul>";
  47  
  48      foreach ($sections as $section) {
  49              $i++;
  50              // we using arrays in the template and objects in the core..
  51              if(isset($params['sections'])) {
  52                     $url = $section['url'];
  53                     $nicename = $section['nicename'];
  54              } else {
  55                     $url = $section->url;
  56                     $nicename = $section->nicename;
  57              }
  58  
  59              if($mode=='list') $linkcode .= "<li>";
  60  
  61              $linkcode .= '<a href="'.$url.'">'.$nicename.'</a>';
  62  
  63              if($mode=='list') $linkcode .= "</li>";
  64              else if($num > $i) $linkcode .= $sep;
  65  
  66      }
  67  
  68      if ($mode=='list') $linkcode .= "</ul>";
  69  
  70      return $linkcode;
  71  }
  72  
  73  /* vim: set expandtab: */
  74  
  75  ?>


[ Powered by PHPXref - Served by Debian GNU/Linux ]