01204: pagelist frontlinks

Summary: pagelist frontlinks
Created: 2010-06-15 15:52
Status: Open
Category: Feature
From: simon
Priority: 554
Version: 2.2
OS: Any

Description: Pagelists currently support back links - i.e., it returns a list of pages with a link to the target..

This is a feature request to support front links - i.e., it returns a list of pages with a link from the target.

Essentially this is the same as trail, but removes the restriction of the link having to appear in list markup.

The use case for this is to build, using a pagelist, a hierarchical pagelist, similar to

(:template first:)
!! Group {$$group} [-{$$name}-]
(:template each:)
(:pagelist frontlink={=$FullName} fmt=#link list=normal group={$$Group}:)
(:pagelist name=PmWiki/ fmt=#link list=normal group=PmWiki:)

(:template first:)

Group {$$group} {$$name}

(:template each:)

Another use case would be to put in the header or footer a list of all categories on the current page:

This page's categories: \
(:pagelist frontlink={*$FullName} fmt=#categorylisting list=normal order=name group=Category:)


Do you require a new parameter in the pagelist function (which will be complex to implement) or do you just need this feature to work? Because it could be done with an additional PageVariable {$Links} then use it in the pagelist name= parameter:

Links variable:

* {$Links}
* {$NotLinks}
* {PmWiki.PmWiki$Links}
  • PITS.01204,Profiles.Simon,PmWiki.PageLists,PmWiki.PageVariables,Profiles.Petko,Profiles.RandyB,PmWiki.RoadMap,Test.PageListRecursionLink,Test.PageListRecursionTrail
  • -PITS.01204,-Profiles.Simon,-PmWiki.PageLists,-PmWiki.PageVariables,-Profiles.Petko,-Profiles.RandyB,-PmWiki.RoadMap,-Test.PageListRecursionLink,-Test.PageListRecursionTrail
  • PmWiki.WikiWikiWeb,Main.WikiSandbox,PmWiki.BasicEditing,PmWiki.Skins,PmWiki.PmWikiPhilosophy,Cookbook.Cookbook,PmWiki.Installation

The Links/NotLinks PageVariables are defied in local/PITS.01204.php like this:

function uPageTargets($targets, $invert=false) {
  if (!$targets) return "";

  $out = preg_replace('/,![^,]+/', '', $targets);
  if ($invert) $out = preg_replace("/^(?=.)|,/", "$0-", $out);
  return $out;

$FmtPV['$Links'] = 'uPageTargets(@$page["targets"])';
$FmtPV['$NotLinks'] = 'uPageTargets(@$page["targets"], true)';

Petko June 19, 2010, at 02:37 AM

Categories of the Flipbox recipe:

(:pagelist group=Category name={Cookbook.Flipbox$Links} fmt=#categorylisting:)

First 6 links from my profile to Cookbook pages:

(:pagelist group=Cookbook name={Profiles.Petko$Links} count=6:)
Cookbook /
ActionMenu  Drop-down menu to page actions (Edit, History, Attach...) instead of links. (Beta)
AddToWatchlist  Add or remove a page from your watchlist trail with a single click (beta)
AddUrlSchemes  How to get PmWiki to recognize additional URL schemes such as irc:, nntp:, etc.
Ape  Embed videos, maps, documents, and more in wiki pages (Stable)
AsSpacedFunctionInUTF-8  How to fix the broken {$Namespaced}, {$Titlespaced}, {$Groupspaced} when the website is in UTF-8
AttachImageSize  Generate width and height attributes for attached images

Go to page:  1  2 

!! {{$FullName}$Links}
(:template first:)
!!! Group {$$group} . [-{$$name}-]
(:template each:)
(:pagelist name={{=$FullName}$Links} fmt=#linkup list=normal group={$$Group} count=2:)
(:pagelist name={{$FullName}$Links} fmt=#linkup list=normal count=8:)

From a consistency point of view I believe that a separate parameter would be better, but I take your point as to ease of implementation. Thanks simon June 19, 2010, at 06:58 AM

Something, likely the pagelist recursion, breaks the page so I disabled the last test. I'm not sure if pagelist was designed to work in recursion. --Petko June 19, 2010, at 08:17 AM

It's a shame pagelist recursion breaks the page. Even the ability to recurse one level would open up some great possibilities - for example a pagelist that obtains its format from a variable defined on the page to be formatted. Pages with special formatting needs could then specify how they need to be formatted through "Format: MySpecialFmt".

I tried the {$Links} page variable idea. It works on the page, but failed when I put it in the search box above. I entered: group=Category name={Cookbook.Flipbox$Links} fmt=#categorylisting. -- RandyB June 19, 2010, at 04:23 PM

Other variables like {Cookbook.Flipbox$FullName} or just {$FullName} don't work either. Is it likely that your users are going to use it a lot from a searchbox? --Petko June 19, 2010, at 04:45 PM

I don't know about "a lot", but I can see sometimes wanting to do it from a search box. For example if I want to see the page summary for all the categories on this page (which are likely on a single line of markup), it would be nice to be able to type a command into the search box, as opposed to edit the page to create a pagelist.

Another issue is the consistency between the pagelist and searchbox. When I generate a pagelist-created report, users see the options that were used. This allows the user to copy and paste the query into the searchbox for experimental and iterative tweaking - it's seamless. I'd rather not tell the user "Except you can't do that for this particular pagelist report." -- RandyB June 19, 2010, at 06:00 PM

PageVariables are expanded when the line is in the page, but not when it is in the searchbox. Can you show the exact line containing other page variables, which worked from the searchbox? I think the seamless experimental and iterative tweaking can be done by pressing the "Preview" button in the page (with version 2.2.9 or newer). --Petko June 19, 2010, at 06:15 PM

I don't think I've ever been able to put page variables in the searchbox. But then I've never had as big a temptation as {$Links}. The Preview idea should work, but it means having to explain a new process to users - not as user-friendly. Besides, what if the user is on a page for which he or she has no edit rights? -- RandyB June 19, 2010, at 06:30 PM

I don't disagree. There is indeed a planned linkfrom= pagelist attribute in PmWiki.RoadMap so it will happen some day. Meanwhile, about your request ("see the page summary for all the categories on this page"), I'd probably prefer a simple link in a GroupFooter (or SideBar, or PageActions...) that would point directly to the search query, something like this. --Petko June 19, 2010, at 06:48 PM

* [[{*$FullName}?action=search&q=group=Profiles+name={*$Links}|list categories]] (this PITS page has no categories, demo with group Profiles)
  • list categories (this PITS page has no categories, demo with group Profiles)

I have used pagelists within pagelists. Should I create a PITS for recursive pagelists? simon June 19, 2010, at 09:13 PM

It appears that recursion more or less works, see Test.PageListRecursionLink and Test.PageListRecursionTrail, so the issue with the suggestion above may be with the PV. So perhaps a pagelist parameter is better. simon July 15, 2010, at 01:52 PM