package WebGUI::Macro::ParentPageURL; use strict; use WebGUI::Macro; use WebGUI::Session; =head1 NAME Package WebGUI::Macro::ParentPageURL =head1 DESCRIPTION Macro for returning the parent page url for the current page. This will work the same as the RootTitle macro with the exception of the ability to pass in the asset ID for the "root" page which will be excluded. =head2 Example Home -> WebGUI Development -> API -> Documentation -> Macros -> Macro Skeleton -> Taking advantage of WebGUI APIs If the macro is used in the template as ^ParentPageURL(); then home is excluded from any results. The url "/webgui/dev" would be displayed when any of the sub-pages (or sub-sub-pages, etc) are viewed. =head1 AUTHOR Lenny Leblanc, =cut #---------------------------------------------------------- sub process { my $session = shift; my $root = shift; return "" unless $session->asset; my $asset = $session->asset; my $parent = $asset->getParent; if($asset->getId ne $root){ #we are going to stop at the asset id presented while($parent->getId ne $root) { $asset = $parent; if($asset->getParent) { $parent = $asset->getParent; } else { return $asset->get('url'); } } } return $asset->get('url'); } 1;