|
Cookbook /
Cluster-TalkThis 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;
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. 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. 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 There's a bug in locating GroupAttributes. Create and set attributes on:
Then look at:
You'll see that the Kingdom-Animal/HomePage attributes are not set by Kingdom-Animal/GroupAttributes, but Kingdom/GroupAttributes. The fix is simple. Edit cluster.php and around line 161 alter:
if (!$found_attr && PageExists("$cluster_group.GroupAttributes")) {
$GroupAttributesFmt = "$cluster_group.GroupAttributes";
$found_groupfoot = true;
}
to:
if (!$found_attr && PageExists("$cluster_group.GroupAttributes")) {
$GroupAttributesFmt = "$cluster_group.GroupAttributes";
$found_attr = true;
}
sborrill October 24, 2009, at 10:49 AM Hi, Is there a way to use '/' as a group separator, such that people using SEO friendly urls like Main/HomePage can use forward slash for navigating subgroups as well? Thanks. farhad December 17, 2009, at 10:07 AM |