The best location for functions, js and css
Permalink 2 users found helpful
Hi,
Where is the best location for function js, css used both by a dashboard single page and a block view in a package ?
I don't know if my question is stupid..
Thanks,
Seb
Where is the best location for function js, css used both by a dashboard single page and a block view in a package ?
I don't know if my question is stupid..
Thanks,
Seb
in blocks, you can have css and js auto added to the header,
for example:
/blocks/<blockname>/
can have the following folder structure,
/css
something.css
/js
something.js
somethingelse.js
controller.php
view.php
add.php
edit.php
and anything in the /css and /js folders will automatically be added to the header
for example:
/blocks/<blockname>/
can have the following folder structure,
/css
something.css
/js
something.js
somethingelse.js
controller.php
view.php
add.php
edit.php
and anything in the /css and /js folders will automatically be added to the header
True, but I think the question was specifically about where to include js/css that's used by BOTH a block and a single_page -- if you put it in the block, then the single_page can't access it.
Thanks Jordan.
it's the best way for js and css.
For PHP functions, the best place is it to put them in a tools folder at the top level of the package and to embed them with
the get tools function..?
it's the best way for js and css.
For PHP functions, the best place is it to put them in a tools folder at the top level of the package and to embed them with
the get tools function..?
What kind of php functions? Are they utility functions that can be called by code, or are they ajax responses to URL calls? I think the "tools" directory is for ajax responses (or other things that will be called by a page URL), but the "libraries" directory is for utility functions that will be called by other code.
Thanks Jordan,
Thank you. I've never really known the role of libraries, and now I know exactly what I need.
Thank you. I've never really known the role of libraries, and now I know exactly what I need.
What I would do is put the javascript in a directory called "js" at the top-level of your package, and put the stylesheet in a directory called "css" also at the top-level of your package (so your package folder would look something like:
blocks/
controller.php
css/
js/
single_pages/
Now you have them in one place, but I think you need to call them from both the block controller and the single_page controller. Pass the package handle as the second argument to the javascript and css helper functions, like so:
Hope that helps!
-Jordan