using a package in composer write

Permalink
Hi all. i have a error :O please can anyone help?

Fatal error: Call to a member function canWrite() on a non-object in C:\xampp\htdocs\sites\gibson\packages\gal_side_thumbs\blocks\gal_side_thumbs\view.php on line 22

basically i need to stop my package from working when the user is logged in because the jquery used in the package conflicts with the concrete5 toolbar.

so i have wrapped my packages view.php in an if statement like this:

global $cp; if ($cp->canWrite()) {
// output
}

this works! but when i use this package in composer it gives the error when the user updates the file set that the package is using.

chris123uk
 
synlag replied on at Permalink Best Answer Reply
synlag
Hi,

instead of using global, try:

$cp = new Permissions(Page::getCurrentPage());
if ($cp->canWrite() && $cp->canEdit()) {
// do stuff
}


Does it work?
Greets
chris123uk replied on at Permalink Reply
chris123uk
thanks.