Concrete 5.8 , page in dashboard - Call to a member function generate() on a non-object

Permalink 1 user found helpful
Hi

I have a problem with apply my addon from Concrete 5.7 to 5.8 .

I didn't have problem with install but in dashboard.

When I go to page in my package, I can see error:

Call to a member function generate() on a non-object

So I ran debbug mode and the problem is in "/concrete/themes/dashboard/view.php" file in line 10.
The problem is $token variable . It's NULL.
<a href="#" class="ccm-dashboard-page-header-bookmark" data-page-id="<?php echo $c->getCollectionID()?>" data-token="<?php echo $token->generate('access_bookmarks')?>" data-bookmark-action="<?php if ($_bookmarked) { ?>remove-favorite<?php } else { ?>add-favorite<?php } ?>">

To resolve this problem I have to edit /concrete/themes/dashboard/view.php by adding:

$token = Core::make('helper/validation/token');


How can I resolve problem without edit core ?

IceManSpy
 
MrKDilkington replied on at Permalink Reply
MrKDilkington
Hi IceManSpy,

I cannot confirm this. I tested with a 5.7 to v8 install and a fresh v8 install.

When I check the value of $token in that file, it is a Concrete\Core\Validation\CSRF\Token class object.

Do you see this error only when you use a specific add-on?
IceManSpy replied on at Permalink Reply
IceManSpy
It is my addon - dsEventCalendarPro for Concrete 5.7.

If you want, I can add you license to test it.

I've tested on fresh instance of Concrete 5.
MrKDilkington replied on at Permalink Reply
MrKDilkington
@IceManSpy

If you grant me a license, I will test with it.
IceManSpy replied on at Permalink Reply
IceManSpy
I granted license.
Please, check it, because I don't know, why my add on make conflict with core.
MrKDilkington replied on at Permalink Reply
MrKDilkington
@IceManSpy

The problem is in your single page controllers. You are adding a CSS file to your views using the on_before_render() method. This is breaking the dashboard view.
public function on_before_render()
{
    $this->addFooterItem(Loader::helper('html')->css('dsStyle.css', 'dsEventCalendarPro'));
}

As a solution, I beleive you can add $this->addFooterItem(Loader::helper('html')->css('dsStyle.css', 'dsEventCalendarPro')); inside your view() method.
IceManSpy replied on at Permalink Reply
IceManSpy
Thank you.

I think, that is good solution.
I will release new version with this fixes.
Cahueya replied on at Permalink Reply
Have you tried this solution and it worked? I am facing the same error message on a custom block but the fix did not do anything. Where have you put the css reference?

Thank you!
IceManSpy replied on at Permalink Reply
IceManSpy
Yes, it helped me to my addon.