Watch what I did to use different layouts to different specific views:

In app_controller.php :


    function beforeRender(){
        if(isset($this->params[Configure::read('Routing.admin')])){
            $this->layout = 'default_admin';  // Uses layout for /admin/
pages
        }
        if(property_exists($this, 'customLayouts') &&
is_array($this->customLayouts)){

            if (sizeof($this->customLayouts) &&
array_key_exists($this->action, $this->customLayouts)){
                $this->layout = $this->customLayouts[$this->action];
            }

            if(array_key_exists($this->action, $this->customLayouts) &&
$this->customLayouts[$this->action] == 'empty'){
                Configure::write('debug', 0);
            }
        }
    }


And in each controller I define desired layouts for specific methods, like
this:

        var $customLayouts =  array(    'admin_ajaxDeleteImage' => 'empty',
                                        'index' => 'empty',
                                        'admin_ajaxGetVideosFromArtist' =>
'empty');


It will use layout "empty" when VideosController::admin_ajaxDeleteImage() is
ran.





On Mon, May 12, 2008 at 4:45 PM, MarcS <[EMAIL PROTECTED]> wrote:

>
> Is it possible to include CSS and Javascript into a layout based on
> what the specific view requires?
> I would like to use one layout for all my views but there are some
> javascript libraries that are onl required for very few actions.
>
> I remember reading that this is possible a while back but I can't seem
> to find anything about it.
> Could someone provide some pointers where to look for info about this?
>
> thanks in advance,
> Marc
> >
>


-- 
Nicolás Andrade
www.nicoandra.com.ar
www.treintaguita.com.ar

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to