Reputation: 9807
What is the correct syntax for including an external js and external CSS file in CakePHP so that these files are included in the <head>
from within a view?
By external I mean something like "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/base/jquery-ui.css" but I want to place it conditionally in a single view.
Upvotes: 2
Views: 3746
Reputation: 3204
The answer from xiaohouzi79 is correct for Cake 1.2, but the JavaScript helper has been deprecated in Cake 1.3 (documentation).
CSS (documentation):
$html->css(array('http://example.com/type.css', 'http://example.com/color.css'), null, array('inline' => false));
JavaScript (documentation):
$html->script(array('http://example.com/script.js'), array('inline' => false));
Upvotes: 4
Reputation: 9807
For css use the following:
$html->css('http://code.google.com/apis/maps/documentation/javascript/examples/standard.css', false, array('inline' => false));
For a javascript file use the following:
$javascript->link('http://maps.google.com/maps/api/js?sensor=false', false);
btw. don't forget to include the javascript helper in the model.
Upvotes: 0