Saturday, January 31, 2009

Re: $scripts_for_layout breaks in seperated header

My advice is to leave the head section in the layout. Elements/views
are rendered before the layout. Moving the head section to there would
mean, as you're finding out, that you may as well rewrite both the
HtmlHelper & JavascriptHelper yourself.

As far as inline js/css goes, I think you missed some parameters for
those methods:

HtmlHelper::css( $path, $rel = NULL, $htmlAttributes = array ( ),
$inline = true )
JavascriptHelper::link( $url, $inline = true )
JavascriptHelper::codeBlock( $script = NULL, $options = array ( ) )

The last one's a little confusing. Just add 'inline' => false to the
options array. I think the Cake devs chose the wrong default for
$inline for all of these but that's just me.

Echo the basic javascript tags required in your head (in the layout)
followed by the $scripts_for_layout var. Any other scripts you may
require can be echoed in the view/element with $inline set to false
and it'll be added to the $scripts_for_layout var (and, ultimately, to
the head eection).


On Fri, Jan 30, 2009 at 7:11 PM, mlecho <saltlessbread@gmail.com> wrote:
>
> hi-
> in my app, i have sperated the header and footer as new elements
> (header.ctp/footer.ctp). The default.ctp uses $this->element('header')
> for example, to retrieve the header. I am doing this becuase i have
> to change headers/footers from layout to layout (sometimes). Anyway,
> by seperating the header $scripts_for_layout suddenly becomes broken:
> Notice (8): Undefined variable: scripts_for_layout, leavine me with
> the only option of inline css/js. Ugh.
>
> is there a way to work around this? In the views i would like to call
> specific javascripts or css, as some js/css is not pertinant to other
> pages. Thanks
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: