Recent Changes - Search:

Cookbook

PmWiki

pmwiki.org

Cluster-Talk

This is the page to talk about Cluster.

Handy markup to fetch the last name of a cluster style page tile (for home pages in the format of $Group.$Group where $Group is a cluster)

Markup('[[|-', '<[[|',
  "/(?>\\[\\[([^|\\]]+))\\|\\s*-(-?)\\s*]]/e",
  "Keep(MakeLink(\$pagename, PSS('$1'),
                 FeralLastElement(MakePageName(\$pagename,PSS('$1') ), PSS('$2') )
                ),'L')");

function FeralLastElement($what, $how=null)
{
    global $AsSpacedFunction;
    global $ClusterSeparator;

    $pagename = ResolvePageName($what);
    $m = preg_split('/[.\\/]/', $pagename);
    $group = $m[0];
    $name = $m[1];

    if    (    $group == $name)
    {
        $results = explode($ClusterSeparator, $name);
        $element = array_pop($results);
    }
    else
    {
        $element = $name;
    }

    if    (    $how)
    {
        $element = $AsSpacedFunction($element);
    }

    return $element;
}

This simply adds two link shortcuts as convenience items;

  1. [[link|-]] which displays cluster page's last element.
  2. [[link|--]] which displays cluster page's last element as ran though $AsSpacedFunction();
Feral March 24, 2007, at 12:18 PM

I think I found a typo in ClusterSlice() function - there's a $ClusterEnableSpaced instead of $ClusterEnableSpaces - which disables the spaced names.

Jarnik? June 25, 2007

Thanks! Fixed now. Kathryn Andersen June 25, 2007, at 05:24 PM


Does anyone happen to have managed to get Recent Changes pages to inherit? To stick with the usual example, I'd like Animal.RecentChanges to list all recent changes in Animal and Animal-Canine and Animal-Feline Anke December 30, 2007, at 10:59 AM

No, cluster doesn't do that. I'm not sure how to change it to do that, either.
Kathryn Andersen December 30, 2007, at 05:14 PM

I figured something out; No idea if there's a more elegant solution. I put the following in my config.php - I'm using no level deeper than 4 at the moment - and it seems to work, and not try to create pages with invalid names like $g1--.RecentChanges, either.
$pagename = ResolvePageName($pagename);
$level = ClusterCountLevels($pagename);
if ($level > 1){
$Changes = array(
  '$g1.RecentChanges' =>
    '*[[{$Group}.{$Name}|$Group - $Titlespaced]],  $CurrentTime $[by] $AuthorLink: $ChangeSummary ');
  $RecentChangesFmt = array_merge($RecentChangesFmt, $Changes);
}
if ($level > 2){
$Changes = array(
  '$g1-$g2.RecentChanges' =>
    '*[[{$Group}.{$Name}|$Group - $Titlespaced]],  $CurrentTime $[by] $AuthorLink: $ChangeSummary ');
  $RecentChangesFmt = array_merge($RecentChangesFmt, $Changes);
}
if ($level > 3){
$Changes = array(
  '$g1-$g2-$g3.RecentChanges' =>
    '*[[{$Group}.{$Name}|$Group - $Titlespaced]],  $CurrentTime $[by] $AuthorLink: $ChangeSummary ');
  $RecentChangesFmt = array_merge($RecentChangesFmt, $Changes);
}

Anke December 31, 2007, at 06:39 AM

Edit - History - Print - Recent Changes - Search
Page last modified on December 31, 2007, at 06:39 AM