views:

47

answers:

1

I need to use some fairly complex Jquery plugins that aren't just a single .js file, but rather need an entire folder that contains css, images, etc.. I am not understanding how to include this using cakephp, I suppose I could do it from the layout in a traditional HTML manner, but it would be nicer to just do it the Cakephp way, the jquery plugin tells me to do this to include the folder:

<link id="bespin_base" href="/path/to"/>

But I don't quite get how to do this in cakephp.. would it be my server-side path, such as "/var/www/jquery/plugin.. etc"? Thanks for any info..

the way I normally include a jquery plugin is just like this, and similar for css but I don't want to have to manually include each file:

echo $html->script('plugin', false);
A: 

What I tend to do, because I prefer to maintain the Cake structure is place any .js files in app/webroot/js/ and place related assets in their corresponding Cake directory (e.g. app/webroot/css or app/webroot/img). Usually, this means modifying the plugin's CSS so that any url() declarations point to /img/... rather than the relative path that they usually have by default.

If you don't mind being "atypical" and want to keep it simply, then just drop everything into app/webroot/js/jquery/plugin-name/ (or something similar of your own creation). That will mix js, css and images in one directory, but there's nothing wrong with that, per se. Then, using your HTML helper, you'd reference:

echo $html->script( 'jquery/plugin-name/plugin-file.js', false );

(precise syntax may vary slightly)

Rob Wilkerson
thanks, I will try that
Rick