PagelistByCategory

Summary: List pages by Category
Version: Production
Prerequisites: 2.2.79, useful to have Cookbook.PageListMultiTargets
Status: Production
Maintainer: Simon
Categories: PageList MarkupOnly
Users: +1 (view / edit)

Questions answered by this recipe

How do I list pages by category?

Description

Use the following page list template to create a list of pages by Category.

Installation

Add the following to your page

>>comment<<
[[#listbycategory]]
(:template defaults group=Category name=-Category.{$DefaultName} order=$Name ForGroup={$Group} ForName=*:)
(:template each:)
(:pagelist group={$$ForGroup} name={$$ForName} link={=$FullName} ForCategory="{=$Namespaced}" fmt={$Group}.{$Name}#listofcategory count={$$ForCount}:)
[[#listbycategoryend]]
>><<

>>comment<<
[[#listofcategory]]
(:template defaults group={$Group} order=$Name:)
(:template first:)
!! [[Category/{$$ForCategory}]]
(:template each:)
* [[{=$FullName} | {=$Titlespaced}]]
(:template last:)
[[#listofcategoryend]]
>><<

Configuration

The pagelist parameters ForGroup and ForName specify the groups and pages for which the list by category is to be created.

The pagelist parameter name can be used to include or exclude categories.

The pagelist parameter group is by default the Category group.

Usage

Use the recipe as follows, adjusting the markup to suit

(:div190 class=smaller:)
(:pagelist ForGroup={$Group} ForName=-Template,-SideBar,Pagelist* name=-{$DefaultName},PageList fmt={$Group}.{$Name}#listbycategory ForCount=1 count=1:)
(:div190end:)

Notes

Two levels of pagelist are required.

The first (invocation) pagelist enumerates the category pages.

The second (embedded) pagelist checks the category backlinks that confirm a page is categorised.

Pages with no categories are omitted.

On large wikis this recipe may fail by running out of memory. For example even at its most reduced with counts of 1, only one category (PageList), and restricted pages (Cookbook/Pagelist*), as shown in the invocation above it does not run on PmWiki.

Change log / Release notes

If the recipe has multiple releases, then release notes can be placed here. Note that it's often easier for people to work with "release dates" instead of "version numbers".

See also

Contributors

Comments

See discussion at PagelistByCategory-Talk

User notes +1: If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.