Tuesday, February 8, 2011

V1.3 use of plugins vs vendors: accessing css, js, images, etc.

Hello,

I'm trying to get a tabs class (written by a 3rd party) to work well
with Cake. I started out using it as an app/vendors/apphp_tabs just
like the tcpdf class is... but the tabs class wants to access other
files within the same directory structure.

I read a little more, and Cake v1.3 says that "vendors" is going
away... use plugins... I have the following directory structure:
app\plugins\apphp_tabs\webroot\
config\
docs\
examples\
inc\
js\
license\
styles\
tabs_class.php

I have the import in the one (and only) controller of interest right
now:
App::import('Plugins', 'apphp_tabs.tabs_class.php');

Inside the tabs class - used inside the view - with $tabs = new
Tabs(...);
$this->style = 'xp';
$this->path = 'C:/xampp/htdocs/ezShoot_v5/app/plugins/
apphp_tabs/webroot/';
if(file_exists($this->path."styles/common.css"))
echo "<link href='".$this->path."styles/common.css'
rel='stylesheet' type='text/css' />";

Even though php thinks the file exists, the href will never find it
since it's outside of app/webroot. FireBug always reports
"undefined!" So, I resorted to trying to load the css and js in the
view, prior to creating an instance of the Tabs Class:

define ('TABS_CSS', 'C:/xampp/htdocs/ezShoot_v5/app/
plugins/apphp_tabs/webroot/styles/');
$icss = TABS_CSS . "common.css";
echo $this->Html->style('<style>' . file_get_contents($icss) . '</
style>');

and basically the same thing with ->scriptBlock() to handle the
javascripts. All of these are just inline since it's happening in the
view.

Now, the question? Isn't the idea behind the plugins and the new
plugins/apphp_tabs/webroot/ supposed to lead to magic for the js,
and css, and img? But how can the href refer to something outside of
webroot?

I'm a newbie, so maybe I'm missing something simple...

Thanks in advance,
Greg


--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate