Help With Error

The place to talk about things that are related to CMS Made simple, but don't fit anywhere else.
Post Reply
vipernet
New Member
New Member
Posts: 7
Joined: Sun Sep 01, 2013 10:02 pm

Help With Error

Post by vipernet »

Good day all,

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
The code is :
{global_content name='side_nav'}
side_nav =

Code: Select all

<div id="side_nav">{build_side_nav}</div>
forgot the opt Script:
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" />&nbsp;' . $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" />&nbsp;' . $content->Name() . '</span>';
} else {
echo '<a href="' .$content->GetURL() . '">' . $content->Name() . '</a>';
}

echo '</li>';
}
}
}

echo '</ul>';

}
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: Help With Error

Post by velden »

I don't know much about this but I believe the $gCms variable does not exist anymore in newer versions.

Use cmsms() instead

http://docs.cmsmadesimple.org/tags/user ... ting-a-udt
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: Help With Error

Post by calguy1000 »

This is a problem with your PHP code... not a CMS issue. Google the error, it will tell you about it.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
vipernet
New Member
New Member
Posts: 7
Joined: Sun Sep 01, 2013 10:02 pm

Re: Help With Error

Post by vipernet »

Thank you both for your reply.

I had it working on version 1.6.7. Now I upgraded to 1.11.7 still getting errors.
I read the link you gave me velden. I changed the following:

Code: Select all

global $gCms;
to

Code: Select all

 $gCms = cmsms();
That worked great, well got ride of the error on line 4

Still getting fatal Error on :

Code: Select all

$currentURL = $currentNode->getContent()->GetURL();
If anyone see's whats wrong with that please let me know.

Thanks all,
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1974
Joined: Mon Jan 29, 2007 4:47 pm

Re: Help With Error

Post by Jo Morg »

I believe the problem comes from this bit:

Code: Select all

$thisPage = $gCms->variables['page_name'];
on line 7 of your post. AFAIK direct access to the variables has been removed at some point in CMSMS development.
An easy way to get around that would be to call the UDT like this:

Code: Select all

<div id="side_nav">{build_side_nav this_page=$page_alias}</div>
and then in the UDT use

Code: Select all

$thisPage = $params['this_page'];
to replace the previous line 7...
Obviously you can optimize the code even more, there is an obvious line too many, but at least it should work.
HTH

ps: there is an obvious disclaimer - there may be other issues with the UDT that I may not be able to pin point atm....
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
vipernet
New Member
New Member
Posts: 7
Joined: Sun Sep 01, 2013 10:02 pm

Re: Help With Error

Post by vipernet »

I made those two changes:

UDT:

Code: Select all

ini_set('display_errors',1);
error_reporting(E_ALL|E_STRICT);

$gCms = cmsms();

$manager =& $gCms->GetHierarchyManager();
// $thisPage = $gCms->variables['page_name'];
$thisPage =  $params['this_page'];
$currentNode = $manager->sureGetNodeByAlias($thisPage);

// Get the URL to create menu indicator
$currentURL = $currentNode->getContent()->GetURL();

Global Content Block to :

Code: Select all

<div id="products_side_nav">{build_side_nav_cobra this_page=$page_alias}</div>
When I add this to template:

Code: Select all

{global_content name='cobra_side_nav_products'}
This getting the error:
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 12
Been at this for awhile now. think I need to walk away and take look again, prob something stupid lol.
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: Help With Error

Post by Dr.CSS »

Can I ask what you expect this code to do..?
Post Reply

Return to “The Lounge”