This is what i did some time ago:

File: app_controller.php (so every controller has it for free)

 function beforeRender(){

                //Load a controller specific CSS
                if( file_exists(CSS.$this->name.'.css') ){
                        $this->set('controllercss_for_layout',$this-
>name);
                }

                //Load a controller specific Javascript
                if( file_exists(JS.$this->name.'.js') ){
                        $this->set('controllerjs_for_layout',$this-
>name);

                }

               /*
                  .....
                  .....
                */

        }




On Oct 8, 10:53 am, "David C. Zentgraf" <[EMAIL PROTECTED]> wrote:
> I'll play around with that, thanks.
>
> A new undocumented goodie every day... ;-)
>
> On 8 Oct 2008, at 16:54, grigri wrote:
>
>
>
> > What about $this->addScript() ?
>
> > From the view:
>
> > $this->addScript("<!-- whatever you want here -->");
>
> > Adds it internally to the $scripts_for_layout variable; it's called
> > from HtmlHelper::css() and whatnot.
>
> > hth
> > grigri
>
> > On Oct 8, 3:19 am, "David C. Zentgraf" <[EMAIL PROTECTED]> wrote:
> >> I'm using the HeadHelper to do exactly what you want to 
> >> do.http://rossoft.wordpress.com/2006/03/28/register-head-tags-from-helpe
> >> ...
>
> >> On 8 Oct 2008, at 11:16, BrendonKoz wrote:
>
> >>> Ah, teknoid...  I've seen that solution before, albeit with  
> >>> different
> >>> variable names, but that would be the exact solution I was looking
> >>> for.  Thanks.
>
> >>> The reason I don't want to create separate CSS files (usually the  
> >>> best
> >>> solution) is two-fold.
> >>> 1. I can't think of a way to apply IE conditional styling with  
> >>> Cake's
> >>> built in $html->css() method unless I create a layout specifically  
> >>> for
> >>> this purpose - but without the additional variable in the layout  
> >>> that
> >>> you suggested, I probably wouldn't have figured out how to do that
> >>> properly anyway.
> >>> 2. I'd rather not have multiple stylesheets specific to a single web
> >>> address on the server - that can add up rather quickly.  I foresee
> >>> administration wanting other forms recreated on the web, and with  
> >>> just
> >>> 30 forms, that approximately 90 CSS files unrelated to core CSS  
> >>> styles
> >>> for regular layout.
>
> >>> I've used the default.ctp layout supplied by Cake's core so often to
> >>> recreate functionality, I completely forgot I could add my own
> >>> variables to it, and that they would be accessible from my views.
> >>> Thanks again.
>
> >>> On Oct 7, 7:02 pm, teknoid <[EMAIL PROTECTED]> wrote:
> >>>> To me it seems that you've shut down the best option (creating a
> >>>> separate CSS file)... why not create one?
>
> >>>> On the other hand you could try something like that in the layout:
> >>>> if(isset($additional_css)) { echo $additional_css; }
>
> >>>> in the view:
> >>>> $this->set('additional_css', '<style> //your css code </style>');
>
> >>>> On Oct 7, 5:48 pm, BrendonKoz <[EMAIL PROTECTED]> wrote:
>
> >>>>> I have some page-specific code (CSS in this case) that I would
> >>>>> like to
> >>>>> use on a form.  This code will *not* be used anywhere else in my
> >>>>> application, and if replicated, only portions of it will be.  I'd
> >>>>> rather not have to create separate CSS files to use this.  I
> >>>>> looked at
> >>>>> $html->css() and $html->style() without success.  Is there another
> >>>>> method to input *whatever* code I'd like directly in to
> >>>>> $scripts_for_layout?
>
> >>>>> The specific code I need to insert can be found at the following
> >>>>> pastebin address:http://pastebin.com/m28c87fd2
>
> >>>>> I do plan on reusing the layout I created for this, for other  
> >>>>> forms,
> >>>>> but the CSS is specific to this individual form (a recreation of a
> >>>>> paper form, and must retain the same look for legal reasons).
>
> >>>>> Although I could use $html->css for two of the three CSS sections
> >>>>> (I'd
> >>>>> prefer not to however), that specific class method is not made to
> >>>>> handle IE conditional CSS statements for insertion.  Has anyone  
> >>>>> come
> >>>>> up with any solutions to this in their own projects, or have any
> >>>>> ideas
> >>>>> on a possible solution?
>
> >>>>> Note: The linked CSS file has not yet been converted for use  
> >>>>> within
> >>>>> Cake, but that's not the issue here.- Hide quoted text -
>
> >>>> - Show quoted text -
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to