|
Archive /
Sidebar-stylePageListSummary: See PagelistTemplateSamples? Status: Version: Prerequisites: pmwiki-2.0 Maintainer: Categories: Superceded Votes: QuestionHow do I make a (:pagelist:) format whose output resembles that of !Group A * Page 1 * Page 2 * Page 3 !Group B * Page 4 * Page 5 * Page 6 in order to automate sidebar updates? (For example, what if you wanted the sidebar to automatically list all normal pages in the Portfolio and Category groups?) AnswerThis recipe is superceded by PmWiki's use of PageListTemplates, from version 2.1.beta15 onwards. Insert the following code into your config.php:
### Creates the sidebar pagelist format, combination of JR and Hans' solutions plus Bronwyn's mods
## add fmt=sidebar to pagelist options.
## FPLSideBar provides a bullet list of pages organized by group,
## the group displayed as Header1, for use in a SideBar.
$FPLFunctions['sidebar'] = 'FPLSideBar';
function FPLSideBar($pagename, &$matches, $opt) {
global $FPLSideBarStartFmt, $FPLSideBarEndFmt, $FPLSideBarGFmt,
$FPLSideBarIFmt, $FPLSideBarOpt;
SDV($FPLSideBarStartFmt,"<div class='fplsidebar'><ul>");
SDV($FPLSideBarEndFmt,'</ul></div>');
SDV($FPLSideBarGFmt,"</ul><p class='vspace'></p>\n<h1>
<a href='\$ScriptUrl/\$Group'>\$Group</a></h1>\n<ul class='fplsidebar'>\n");
SDV($FPLSideBarIFmt,"<li><a href='\$PageUrl'>\$Title</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']);
}
return FmtPageName($FPLSideBarStartFmt, $pagename) . implode('', $out) .
FmtPageName($FPLSideBarEndFmt, $pagename);
}
## turn off group name with the next line,
## comment it if you want the group name in the list.
#$FPLSideBarGFmt = "";
To use, put a pagelist directive in the appropriate page: (:pagelist group=Main fmt=sidebar list=normal:) See the pagelist documentation? for more information on using the pagelist directive. What does it do?
New and ImprovedThis version is more search-engine friendly since it emulates with the new
## Creates the sidebar pagelist format, combination of JR and Hans' solutions plus Bronwyn's mods
## $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 %sidehead%, for use in a SideBar
function FPLSideBar($pagename, &$matches, $opt) {
global $FPLSideBarStartFmt, $FPLSideBarEndFmt, $FPLSideBarGFmt,
$FPLSideBarIFmt, $FPLSideBarOpt;
SDV($FPLSideBarStartFmt,"<div class='fplsidebar'><ul>");
SDV($FPLSideBarEndFmt,'</ul></div>');
SDV($FPLSideBarGFmt,"</ul><p class='vspace'></p>\n<p class='sidehead'><a href='\$ScriptUrl/\$Group'>\$Group</a></p>\n<ul class='fplsidebar'>\n");
SDV($FPLSideBarIFmt,"<li><a href='\$PageUrl'>\$Title</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']);
}
return FmtPageName($FPLSideBarStartFmt, $pagename) . implode('', $out) .
FmtPageName($FPLSideBarEndFmt, $pagename);
}
## turn off group name with the next line,
## comment it if you want the group name in the list.
#$FPLSideBarGFmt = "";
Notes and Comments
See AlsoContributorsCategory: Layout |