Page 1 of 1

Notice: Trying to get property of non-object in

Posted: Wed Sep 24, 2014 3:24 am
by Purrfectlyyappy
Hi Guys,

I'm working with a joomla site using Hikashop and I'm getting the following message at the top of my screen at the checkout on our website.

Notice: Trying to get property of non-object in /var/www/vhosts/purrfectlyyappy.com/httpdocs/templates/purrfectlyyappy/index.php on line 10
Notice: Trying to get property of non-object in /var/www/vhosts/purrfectlyyappy.com/httpdocs/templates/purrfectlyyappy/index.php on line 11
Notice: Trying to get property of non-object in /var/www/vhosts/purrfectlyyappy.com/httpdocs/templates/purrfectlyyappy/index.php on line 12

This does not apply on any other page on the site apart from the checkout page.

These are the first 13 lines of our index.php code for the site

Code: Select all

<?php

defined('_JEXEC') or die;
$app = JFactory::getApplication();
$leftbar = 1;
$rightbar = 1;
//$active = JFactory::getApplication()->getMenu()->getActive();
$menu = JFactory::getApplication()->getMenu();
$active = $menu->getActive();
$menuname = $active->title;
$parentId = $active->tree[0];
$parentName = str_replace(" ","",strtolower($menu->getItem($parentId)->title));
?>
Any ideas why im getting these warnings? Apologies i am a PHP n00b!!

Thanks

Sam

Re: Notice: Trying to get property of non-object in

Posted: Wed Sep 24, 2014 6:59 am
by Celauran
$active isn't an object. What is it?

Re: Notice: Trying to get property of non-object in

Posted: Wed Sep 24, 2014 8:11 am
by Purrfectlyyappy
I'm not sure what you mean by that? If i were to remove this from the code, what would it affect?

Like i said, apologies but i've never dealt with php before :p

Re: Notice: Trying to get property of non-object in

Posted: Wed Sep 24, 2014 8:39 am
by Celauran
I mean this, basically

Code: Select all

<?php

defined('_JEXEC') or die;
$app = JFactory::getApplication();
$leftbar = 1;
$rightbar = 1;
//$active = JFactory::getApplication()->getMenu()->getActive();
$menu = JFactory::getApplication()->getMenu();
$active = $menu->getActive();
var_dump($active); exit;
What's the output?

Re: Notice: Trying to get property of non-object in

Posted: Wed Sep 24, 2014 9:58 am
by Purrfectlyyappy
I tried making that change above within the code but when i loaded the web page its just said 'NULL' so i haven reverted back to previous code.

This is the url for the page and you can see the exact notice that i am getting at the top of the page - maybe this will help?

https://www.purrfectlyyappy.com/index.p ... p/checkout

Thanks

Re: Notice: Trying to get property of non-object in

Posted: Wed Sep 24, 2014 10:35 am
by Celauran
null is what $menu->getActive() is returning, which is the source of this particular problem. I'll let someone more familiar with Joomla! try to figure out why, as I have no experience with it and their documentation is a mess.

Re: Notice: Trying to get property of non-object in

Posted: Wed Sep 24, 2014 10:48 am
by Purrfectlyyappy
Okay, thanks a lot for your help!