0

I am using CakePHP 2.0 and I want to load a concrete CSS style in a Page. (with no controller but using the Layout).

I know it can be done with scripts using:

$this->Html->script('photos', array('inline' => false));

And then on the Layout:

<?php echo $scripts_for_layout; ?> 

But i have no idea if it exists or not something similar to $scripts_for_layout; for CSS style. Do you know how can i do it?

1 Answer 1

3

If you can upgrade to 2.1 then you can use this:

// in your view
$this->Html->script('carousel', array('block' => 'scriptBottom'));

// in your layout
 echo $this->fetch('scriptBottom');

http://book.cakephp.org/2.0/en/views.html#using-blocks-for-script-and-css-files

update:

In earlier versions you could do it like you do with scripts:

$this->Html->css('some.css', null, array('inline' => false));

And it will be placed to $scripts_for_layout.

Sign up to request clarification or add additional context in comments.

3 Comments

So, is it now possible to do it with older versions of CakePHP? It's something basic!!
Ok thanks!! But there's a little difference with loading of javascript files. There's a null at the middel in here. Oh, and you don't need the echo at the start if you want to load it on the layout and you use it on the view.
That's for sure. I was in a hurry. Sorry. : )

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.