[pmwiki-users] pagelist questions

Hans design at flutesong.fsnet.co.uk
Tue Jul 19 02:42:20 CDT 2005


Tuesday, July 19, 2005, 12:55:18 AM, Bronwyn wrote:
> I'd like to emit a pagelist in a format like this, for use in a sidebar:

> !Group
> * Page 1
> * Page 2
> * Page 3

> I'd also like to:

> - list pages in several *specified* groups (more than one, but not
> everything or all-but-foo)
> - remove the trailing / from group names
> - have a "short" format that gives just the pagenames, without listing
> the group at all

try this, in config.php (or put it in an separate script in cookbook):
this add custom fmt=sidebar for the (:pagelist:), use explained below.
================

## $FPLFunctions is a list of functions associated with fmt= options
SDVA($FPLFunctions, array(
  'sidebar' => 'FPLSideBar',
  'bygroup' => 'FPLByGroup',
  'simple'  => 'FPLSimple',
  'group'   => 'FPLGroup'));

## FPLSideBarSB provides a bullet list of pages organized by group,
## the group displayed as Header 1, for use in a SideBar
function FPLSideBar($pagename, &$matches, $opt) {
  global $FPLSideBarStartFmt, $FPLSideBarEndFmt, $FPLSideBarGFmt,
    $FPLSideBarIFmt, $FPLSideBarOpt;
  SDV($FPLSideBarStartFmt,"<ul class='fplsidebar'>");
  SDV($FPLSideBarEndFmt,'</ul>');
  SDV($FPLSideBarGFmt,"<h1><a href='\$ScriptUrl/\$Group'>\$Group</a> </h1>\n");
  SDV($FPLSideBarIFmt,"<li><a href='\$PageUrl'>\$Name</a></li>\n");
  SDVA($FPLSideBarOpt, array('readf' => 0, 'order' => 'name'));
  $matches = MakePageList($pagename, array_merge($FPLSideBarOpt, $opt));
  if (@$opt['count']) array_splice($matches, $opt['count']);
  $out = array();
  foreach($matches as $pc) {
    $pgroup = FmtPageName($FPLSideBarGFmt, $pc['pagename']);
    if ($pgroup != @$lgroup) { $out[] = $pgroup; $lgroup = $pgroup; }
    $out[] = FmtPageName($FPLSideBarIFmt, $pc['pagename']);
  }

================
Use it in the SideBar like

   (:pagelist group=GroupOne fmt=sidebar:)
   (:pagelist group=GroupTwo fmt=sidebar:)
   (:pagelist group=GroupThree fmt=sidebar:)
   
you need to use a separate markup for each group, since the group
parameter does not accept a list of groups.

If the group name should not appear, set
  $FPLSideBarGFmt = "";

Unfortunately (:pagelist:) does not work inside conditional markup, so
I could not construct an expanding sidebar menu with pagelist
generated list items.
  
Best, 
~Hans                           





More information about the pmwiki-users mailing list