symfony
symfony forum
Home » support » symfony 1.3 and 1.4 » Writing to the Layout Head
Writing to the Layout Head [message #93175] Tue, 09 February 2010 16:15 Go to next message
robwilkerson  is currently offline robwilkerson
Messages: 18
Registered: January 2010
Junior Member
So this seems like a trivial task that should be available in several ways, yet I can't seem to find any information. I suppose I'm searching for the wrong terms, but that's what brings me here. I'm hoping someone can help.

I need to write a bit of Javascript to the head of my layout from a page. Since Symfony may be able to provide a better way of doing so that I can think of right now, I'll just explain what I'm trying to do.

I have a page that displays N widgets. Only the page knows how many widgets it has to render. I need to get that number to a bit of javascript so that it can make certain adjustments if there is only one widget to be rendered. My intent was to write a global variable to the layout that could be accessed by a JS source file. Unfortunately, I can't find a way to write a block of JS (not a source file) to the head section of my layout.

I thought that the javascript_tag() helper might offer that capability, but it appears not. What's the best way of accomplishing this?

Many thanks.
Re: Writing to the Layout Head [message #93189 is a reply to message #93175 ] Tue, 09 February 2010 18:27 Go to previous message
robwilkerson  is currently offline robwilkerson
Messages: 18
Registered: January 2010
Junior Member
Major head slap. I created a slot called 'scripts_for_layout' and included it within the head tags. I can't imagine why I didn't think of this.
Previous Topic:Segmentation fault in server env
Next Topic:obj->setCulture() in doctrine (solved)
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software