When I add the following code to a template I'm getting an error:
Code: Select all
Strict Standards: Only variables should be assigned by reference in /home/content/10/11717410/html/lib/classes/class.usertagoperations.inc.php(265) : eval()'d code on line 8
Fatal error: Call to a member function getContent() on a non-object in /home/content/10/11717410/html/lib/classes/class.usertagoperations.inc.php(265) : eval()'d code on line 11
side_nav ={global_content name='side_nav'}
Code: Select all
<div id="side_nav">{build_side_nav}</div>
ini_set('display_errors',1);
error_reporting(E_ALL|E_STRICT);
global $gCms;
$manager =& $gCms->GetHierarchyManager();
$thisPage = $gCms->variables['page_name'];
$currentNode = &$manager->sureGetNodeByAlias($thisPage);
// Get the URL to create menu indicator
$currentURL = $currentNode->getContent()->GetURL();
if (trim($currentNode->getContent()->Name()) != "Products") {
$currentNode = &$currentNode->getParent()->getParent();
}
echo '<h2>';
if ($currentURL == $currentNode->getContent()->GetURL()) {
echo '<span class="active_product"><img src="images/cobra/red_arrow.jpg" /> ' . $currentNode->getContent()->Name() . '</span>';
} else {
echo '<a href="' . $currentNode->getContent()->GetURL() . '">' . $currentNode->getContent()->Name() . '</a>';
}
echo '</h2>';
// Get all children for the current node (Note: a node isnt a page.)
$sectionNodes = $currentNode->getChildren();
// build the list based on hierarchy of nodes (see "pages" within CMS Content)
if ($currentNode->hasChildren()) {
echo '<ul>';
foreach ($sectionNodes as $sectionNode) {
$pageNodes = $sectionNode->getChildren();
if ($pageNodes) {
foreach($pageNodes as $pageNode) {
// get the content object
$content = $pageNode->getContent();
echo '<li>';
// if it is the current page, add image indicator
if ($content->GetURL() == $currentURL) {
echo '<span class="active_product"><img src="images/cobra/red_arrow.jpg" /> ' . $content->Name() . '</span>';
} else {
echo '<a href="' .$content->GetURL() . '">' . $content->Name() . '</a>';
}
echo '</li>';
}
}
}
echo '</ul>';
}