Hi All,
Bit stumped at the moment. I am running a method of my class and am getting the value but for some reason I cannot return it as it always renders as false.
The method is recursive but I have put help in so I can see what steps are being taken.
# Fucntion to get the top parent of a given guid (Returns a pages guid)
public function getPageTopLevelParentGUID($permalink, $doc)
{
echo "<li>Searching";
$xmlDoc = new DOMDocument();
$xmlDoc->load($doc);
$xpath = new DOMXPath($xmlDoc);
$pageParent = $xpath->query("//site/pages/page[@permalink='$permalink']")->item(0);
if($pageParent->getAttribute("parent") != "")
{
echo "<li>Look Up Parent Permalink";
# i need the parents permalink to check against
$parentPermalink = $this->getNodeValue("name", $pageParent->getAttribute("parent"), "permalink", $doc);
$this->getPageTopLevelParentGUID($parentPermalink, $doc);
} else {
echo "<li>Done";
return $pageParent->getAttribute("guid");
}
}
If I echo $pageParent->getAttribute(“guid”); I get the desired result but If I assign:
$test = $this->getPageTopLevelParentGUID("example", "example");
echo $test;
I get nothing. Am I losing scope in method as it is recursive?