how do i make scripts_for_layout work outside of a view?
scenario:
I have a plugin to manage my menus. the plugin has a helper which i call from my default layout. inside my helper i have
echo $this->Javascript->link('/menus/js/jqueryslidemenu', false);
but nothing gets sent to scripts_for_layout. if i run the helper in a view it works as it should. help. Asked by angelxmoreno, on 25/4/10
1 Answer
Could you be more specific please? Show us the helper code and how you are calling it in the views.
I don't understand how you are using this call inside the helper.
echo $this->Javascript->link('/menus/js/jqueryslidemenu', false);
Assuming that the plugin works if you put that line inside the helper, you should try it like this:
echo $javascript->link('/menus/js/jqueryslidemenu', false);
And remember that in order to use the $javascript helper you should import it in the controller that would render the view (you can put it in the app_controller also if you'll be using it everywhere).
var $helpers = array('Javascript');
I recommend you to read the helpers section in the cookbook http://book.cakephp.org/view/98/Helpers
Also remember to have in your webroot folder the "/menus/js/..." folder, but instead of that is a better practice to have all your .js in the "js" folder like this "/js/menu/..."
Well hope to see your code if nothing of this helps!
Answered by nojoseon 25/4/10
this is my helper
Javascript->link('/menus/js/jqueryslidemenu', false);
$return .= "\n\n";
$return .= $this->_buildTree($SiteMenu, $withChildren);
$return .= "\n";
return $return;
}
}
?>
which i call in my default.ctp but the JS does not get sent to the header
angelxmoreno - on 11/6/10
Your Answer
You can use Creole Wiki Syntax to format your text.
Tagged with
Rating
0
Viewed
267 times
Last Activity
on 11/6/10