CakePHP Quick tip: Adding CSS links to $scripts_for_layout in 1.3

Richard's picture

Got caught with this one upgrading from an older version of CakePHP to 1.3

In your view, to add a css file to the $script_for_layout variable, you used to do this:

<?php $html->css("css_file", null, array(), false); ?>

In 1.3, you have to change this to:

<?php $html->css("css_file", null, array("inline"=>false)); ?>

Must have glossed over that on in the CakePHP 1.3 migration guide.

Comments

Anonymous's picture

In 1.3, helpers should really

In 1.3, helpers should really be accessed via the View's property rather than via the $helper variable in order to prevent collisions:

<?php $this->Html->css("css_file", null, array("inline"=>false)); ?>

Richard's picture

Thanks for the tip

Thanks for the tip :-)

Haven't really had much chance to play with 1.3 yet...

Anonymous's picture

Thanks for the tip. Worked

Thanks for the tip. Worked exactly, but yeah, I included Karl's suggestion of $this->Html instead of just $html

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Post new comment

The content of this field is kept private and will not be shown publicly. If you have a Gravatar account, used to display your avatar.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <c>, <cpp>, <drupal5>, <drupal6>, <java>, <javascript>, <php>, <python>, <ruby>. Beside the tag style "<foo>" it is also possible to use "[foo]".

More information about formatting options