Sooperfish Cannot redeclare callback() error help please
Permalink
Hi there
The complete error I get is:
Fatal error. Cannot redeclare callback() (previously declared in /home/zoosp198/public_html/cms/blocks/autonav/templates/sooperfish/view.php.5) in /home/zoosp198/public_html/cms/blocks/autonav/templates/sooperfish/view.php on line 8
I know this error is usually two instances of sooperfish on the one page, but on all pages I do not receive this error UNLESS I am comparing two different versions of a page with the autonav block on. Is there anyway of fixing that? As I would imagine that a comparison between two page versions would of course have two instances of the menu on!
Please, any help?
The complete error I get is:
Fatal error. Cannot redeclare callback() (previously declared in /home/zoosp198/public_html/cms/blocks/autonav/templates/sooperfish/view.php.5) in /home/zoosp198/public_html/cms/blocks/autonav/templates/sooperfish/view.php on line 8
I know this error is usually two instances of sooperfish on the one page, but on all pages I do not receive this error UNLESS I am comparing two different versions of a page with the autonav block on. Is there anyway of fixing that? As I would imagine that a comparison between two page versions would of course have two instances of the menu on!
Please, any help?
![Remo](/files/avatars/26.jpg)
it's not a very clean solution but you could wrap the function to make sure it doesn't get declared again. Something like this:
Remo is correct - man i type that a lot :)
You could also move this function into your controller which associates it with an object(the block controller) and you wouldn't get this error since it is no longer a function in the global scope of concrete5, but simply wrapping it in a function_exists is really easy and painless :)
You could also move this function into your controller which associates it with an object(the block controller) and you wouldn't get this error since it is no longer a function in the global scope of concrete5, but simply wrapping it in a function_exists is really easy and painless :)
Thanks Scott ;-)
Well, I think he uses the template I published on my blog (http://www.codeblog.ch/2011/12/concrete5-sooperfish-drop-down-navig... )
It's nothing else than a template, doesn't change the controller.. Which is why I think function_exists is the best way to go.
Well, I think he uses the template I published on my blog (http://www.codeblog.ch/2011/12/concrete5-sooperfish-drop-down-navig... )
It's nothing else than a template, doesn't change the controller.. Which is why I think function_exists is the best way to go.
Thank you for the reply, I'm slightly confused though as I'm somewhat new to php and C5.
I have gone into view.php in the autonav sooperfish block template and was about to wrap
with your if (!function_exists... bit
but I'm not sure what you mean by 'your_callback_function'? do I just write that as is, or am I meant to replace that with some id or something from the nav?
Thanks again for your help, and sorry for not understanding straight away.
I have gone into view.php in the autonav sooperfish block template and was about to wrap
function callback($buffer) { return (str_replace('class="nav"', 'class="sf-menu" id="nav"', $buffer)); }
with your if (!function_exists... bit
but I'm not sure what you mean by 'your_callback_function'? do I just write that as is, or am I meant to replace that with some id or something from the nav?
Thanks again for your help, and sorry for not understanding straight away.
that was just an example, go with this
if (!function_exists('callback')) { function callback($buffer) { return (str_replace('class="nav"', 'class="sf-menu" id="nav"', $buffer)); } }
Ohhh so that could have been anything I wanted?
Thanks for the help, it did the trick marvellously. I have a different error that says
Warning: system() has been disabled for security reasons in /home/zoosp198/public_html/cms/concrete/tools/versions.php on line 73
But I need to go to my host about that apparently and see if I can get system() function enabled to allow for python to start.
Thanks again!
Thanks for the help, it did the trick marvellously. I have a different error that says
Warning: system() has been disabled for security reasons in /home/zoosp198/public_html/cms/concrete/tools/versions.php on line 73
But I need to go to my host about that apparently and see if I can get system() function enabled to allow for python to start.
Thanks again!
I understand, i've been there :)
if(!function_exists('callback')){ function callback($buffer) { return (str_replace('class="nav"', 'class="sf-menu" id="nav"', $buffer)); } }
Thanks, it's sorted now apart from a host problem which I'll speak to them about. Thanks for the help!