Error in setAttribute()
Permalink 1 user found helpful
Hi Everyone,
I have to set attribute for particular pages using code, so i have tried the below given code, but it shows Fatal error.
Error:
Any help would be appreciable.
Thank you
Vijay
I have to set attribute for particular pages using code, so i have tried the below given code, but it shows Fatal error.
Loader::model('collection_attributes'); $pages = Page::getByID($pages_id->cID); $pages->setAttribute('reference_number',$unique_id[$i]);
Error:
Fatal error: Call to a member function setAttribute() on a non-object in E:\xampp\htdocs\concrete\job\concrete\models\collection.php on line 220
Any help would be appreciable.
Thank you
Vijay
I think Jared is right here it would appear to be a problem with the $pages_id->CID;
You can run this check
That would also stop the error from appearing as if $pages is not an object then the setAttribute function is not called.
You can run this check
That would also stop the error from appearing as if $pages is not an object then the setAttribute function is not called.
or use the simpler way,
$pages = Page::getByPath('derp'); if(!$pages->isError()) //page is not error
Hi everyone,
First of all thanks for your responses and sorry for my delayed reply.
I have tried your methods to check the $pages, but there is no error in $pages. Its returning page object.
For more details, please refer the attachment.
Any help would be appreciable.
Thank you
Vijay
First of all thanks for your responses and sorry for my delayed reply.
I have tried your methods to check the $pages, but there is no error in $pages. Its returning page object.
For more details, please refer the attachment.
Any help would be appreciable.
Thank you
Vijay
Sorry I have not looked at the attachment yet, but I stumbled across a very similar looking error, when attempting to add a thumbnail to the page,
It turned out the value I was adding was null,
my
attibute was then trying to add,
that caused an error on a non object. could it possibly be the $unique_id[$i] that you are calling?? is actually not reurning anything?
Ill take a look through the attachment later when not at work see if I can be any more fruitful, this was just a quick thought I had while coding last night
It turned out the value I was adding was null,
my
attibute was then trying to add,
$setAttribute('page_thumb',)
that caused an error on a non object. could it possibly be the $unique_id[$i] that you are calling?? is actually not reurning anything?
Ill take a look through the attachment later when not at work see if I can be any more fruitful, this was just a quick thought I had while coding last night
Hi,
Thanks for your reply. Found and solved the problem.
Thanks for your reply. Found and solved the problem.
Is $pages_id->cID a valid page ID?
Jared