[SOLVED]admin: Call member function GetURL() on a non-object

Help with getting the CMS CORE package up and running. This does not include 3rd party modules, PHP scripts, anything downloaded via module manager or from any external source.
Locked
Joppybt
New Member
New Member
Posts: 6
Joined: Fri Aug 22, 2008 11:47 am

[SOLVED]admin: Call member function GetURL() on a non-object

Post by Joppybt »

My problem is solved but I am posting this to maybe help others.

After I upgraded my 1.10.3 site to version 1.11 the public site worked perfectly.
However, whenever I tried to open a page for editing in the admin interface, or tried to save a template I got a 404-page and error in the logfile:

Code: Select all

Call to a member function GetURL() on a non-object in /var/www/XXXXX/tmp/templates_c/c1344001880^55f7216a49f40af311680e5c40b180e7c548bfdb.template.17.php on line 46
The apache errorlog showed a warning just before that with:

Code: Select all

Undefined index: content_obj in /var/www/XXXXX/tmp/templates_c/c1344001880^55f7216a49f40af311680e5c40b180e7c548bfdb.template.17.php on line 46
This led me to the solution. My template had a line:

Code: Select all

<link rel="canonical" href="{$content_obj->GetURL()}" />
which in the default templates is:

Code: Select all

{if isset($canonical)}
    <link rel="canonical" href="{$canonical}" />
{elseif isset($content_obj)}
    <link rel="canonical" href="{$content_obj->GetURL()}" />
{/if}
It appears you need to test for the existence of content_obj.
As I could not edit templates in the admin interface anymore I had to use phpmyadmin to change the template directly in the table cms_templates. After that the problem was gone and I could edit pages again.

I do not remember when I added the canonical part to my template and why I only added the content_obj line but I am leaving this as a warning for other people.

This does leave me with one minor question: is it logical that a template works fine in the normal published site but will throw errors in the admin interface (where a preview is generated I suppose) ?
Last edited by Joppybt on Sat Aug 11, 2012 8:58 am, edited 2 times in total.
migrob
New Member
New Member
Posts: 2
Joined: Fri Aug 10, 2012 9:43 am

Re: In admin: Call to a member function GetURL() on a non-ob

Post by migrob »

I had a similar problem after updating my site from 1.10.3 to version 1.11.
Also the public site worked perfectly.
But whenever I tried to open a page for editing in the admin interface, or tried to save a template I got a 404-page and fatal error:

Code: Select all

Fatal error: Call to a member function getParentNode() on a non-object in /home/lightliv/public_html/schreibmobil/plugins/function.cms_selflink.php on line 257
I then looked at my template and saw that I had 3 lines:

Code: Select all

{cms_selflink dir="start" rellink=1}
{cms_selflink dir="prev" rellink=1}
{cms_selflink dir="next" rellink=1}
As I too could not edit the template in the admin interface, i had to use phpmyadmin and change the template directly in the table 'templates'. I deleted those 3 lines and saved the changed template.

After that everything worked well.
carasmo
Power Poster
Power Poster
Posts: 506
Joined: Thu Feb 08, 2007 6:11 pm

Re: In admin: Call to a member function GetURL() on a non-ob

Post by carasmo »

cms_selflink is buggy?
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: In admin: Call to a member function GetURL() on a non-ob

Post by Dr.CSS »

The canonical stuff should have look like so, not with a bunch of \ in it...

{if isset($canonical)}<link rel="canonical" href="{$canonical}" />{elseif isset($content_obj)}<link rel="canonical" href="{$content_obj->GetURL()}" />{/if}
Joppybt
New Member
New Member
Posts: 6
Joined: Fri Aug 22, 2008 11:47 am

Re: In admin: Call to a member function GetURL() on a non-ob

Post by Joppybt »

Dr.CSS wrote:The canonical stuff should have look like so, not with a bunch of \ in it...

{if isset($canonical)}<link rel="canonical" href="{$canonical}" />{elseif isset($content_obj)}<link rel="canonical" href="{$content_obj->GetURL()}" />{/if}
Thanks, I removed the backslashes in the opening post to prevent confusion.
They were not present in my deployed site. Somehow they got introduced with all my copy-pasting to create this post.
Locked

Return to “[locked] Installation, Setup and Upgrade”