Problem with PHP in Stacks
Permalink
So I'm trying to use some code I found to insert a dynamic header within an H3 of an autonav template.
The following code works great, however once I apply this template to an autonav within a "STACK", It freezes and I can no longer access/edit the stack.
This is the code I am using:
$p = $c->getCollectionParentID();
function recurse($p,$id){
$value = $id;
if($p!=1){
$previd = $p;
$x = Page::getByID($p);
$p = $x->getCollectionParentID();
return(recurse($p,$previd));
}
else{
return $value;
}
}
$p = recurse($p,$c->getCollectionID());
$p = Page::getByID($p);
echo "<a href='".$this->url('/').substr($p->getCollectionPath(),1,strlen($p->getCollectionPath()))."/' ><h3>".$p->getCollectionName()."</h3></a>";
Any help is appreciated.
The following code works great, however once I apply this template to an autonav within a "STACK", It freezes and I can no longer access/edit the stack.
This is the code I am using:
$p = $c->getCollectionParentID();
function recurse($p,$id){
$value = $id;
if($p!=1){
$previd = $p;
$x = Page::getByID($p);
$p = $x->getCollectionParentID();
return(recurse($p,$previd));
}
else{
return $value;
}
}
$p = recurse($p,$c->getCollectionID());
$p = Page::getByID($p);
echo "<a href='".$this->url('/').substr($p->getCollectionPath(),1,strlen($p->getCollectionPath()))."/' ><h3>".$p->getCollectionName()."</h3></a>";
Any help is appreciated.