package WebGUI::Macro::BranchRootPageUrl; #------------------------------------------------------------------- # WebGUI is Copyright 2001-2005 Plain Black Corporation. #------------------------------------------------------------------- # Please read the legal notices (docs/legal.txt) and the license # (docs/license.txt) that came with this distribution before using # this software. #------------------------------------------------------------------- # http://www.plainblack.com info@plainblack.com #------------------------------------------------------------------- # by Rebecca Hunt # www.rebeccahunt.com # returns the url of the page that is the root of the current Branch # that is, the ancester of the current page that is directly below the # WebGUI Root # # Please report any errors or questions to me@rebeccahunt.com use strict; use WebGUI::Session; use WebGUI::Asset; use WebGUI::AssetLineage; #------------------------------------------------------------------- sub process { if (exists $session{asset}) { my $currentPage = $session{asset}; # branch root is the first branch off the root # it will have an abolute depth of two (root is absdepth 1) # walk up our ancestry tree until we find it while ($currentPage->getLineageLength() > 2 ) { $currentPage = $currentPage->getParent(); } return $currentPage->getUrl(); } else { WebGUI::ErrorHandler::warn("session asset does not exist"); } } 1;