Custom helper not found - not referencing external folder?

Permalink
Hi,

I have created a helper that creates a black-and-white image. I have put it into my outside 'helpers' folder and named it 'imagebw.php', with the class name being 'SiteImageBW'.

However on referencing it using
$bw = Loader::helper('imagebw');


I just get
Warning: require_once(/Work/concrete5/concrete5.6.0/concrete/helpers/imagebw.php) [function.require-once]: failed to open stream: No such file or directory in /Work/concrete5/concrete5.6.0/concrete/core/libraries/loader.php on line 279
Fatal error: require_once() [function.require]: Failed opening required '/Work/concrete5/concrete5.6.0/concrete/helpers/imagebw.php' (include_path='/Applications/XAMPP/htdocs/squaredaisy/libraries/3rdparty:/Work/concrete5/concrete5.6.0/concrete/libraries/3rdparty:.:/Applications/XAMPP/xamppfiles/lib/php:/Applications/XAMPP/xamppfiles/lib/php/pear') in /Work/concrete5/concrete5.6.0/concrete/core/libraries/loader.php on line 279


It seems to be looking for the helper within the main package itself, instead of looking for it in the outside /helpers directory for reasons unknown to me! The helper looks fine, it's just a copy of the image helper with a couple of changed lines, so I'm currently unsure as to why it wouldn't be working.

Has anyone else experienced the same issue?

 
ScottSandbakken replied on at Permalink Reply
ScottSandbakken
You need to include the package handle.

$bw = Loader::helper('imagebw',$pkg_handle);
Danives replied on at Permalink Reply
Cheers for the reply - however it's not in a package. Its literally just a helper class I've added in and want to use.
ScottSandbakken replied on at Permalink Reply
ScottSandbakken
I have seen this error if the class name or file name does not match the handle in the helper declaration.

Your file name should be imagebw.php
Your class declaration should be "class ImagebwHelper ..."
Danives replied on at Permalink Reply
Hey,

Tried renaming the class to "ImagebwHelper" but no such joy :(

Also tried "SiteImagebwHelper" and different combinations of upper / lower case with no such luck.

I don't know if it assists, but I am trying to call the Loader from a page list template. I don't know if that means that it immediately looks in the core concrete5 helpers folder.
ScottSandbakken replied on at Permalink Reply
ScottSandbakken
I was able to replicate your error. I then cleared my cache and the error went away. Clear your cache and see if that helps.
Danives replied on at Permalink Reply
Ack! Yep that solved it, why didn't I think of that sooner. Thanks so much for your help :)