Or without modifying pages_controller.php In /app/views/pages/one.ctp (for CakePHP1.2) <?php $this->layout='eggs'; ?> <h1>This page uses the eggs layout</h1>
And, in /app/view/pages/about.ctp <?php $this->layout='bacon'; ?> <h1>This page uses the bacon layout</h1> On Apr 17, 7:59 am, grigri <[EMAIL PROTECTED]> wrote: > If you really need to change the layout per-page, then extending the > page_controller is the way to go. There's a bakery article on this > subject [http://bakery.cakephp.org/articles/view/taking-advantage-of- > the-pages-controller] > > Basically, if you have a page called 'faq' then the pages controller > method 'faq' will be called (if it exists), so you'd go: > > class PagesController extends AppController { > // ... > > function faq() { > $this->layout = 'eggs'; > } > > function about() { > $this->layout = 'bacon'; > } > > // ... > > } > > Do I really need to make an *empty* model, an *empty* database table > > and an *empty* controller - just to set the layout of a static page? > > Nope. You do need a controller, but not a model or database table. The > pages controller is an example of how to do this. > > ------------------------------ > > If it's just a matter of the javascript though, that doesn't require a > different layout [assuming you're on 1.2 - you didn't say]: > > /app/views/pages/one.thtml > > <h1>This page has no extra script</h1> > <p>blabla bla</p> > > /app/views/pages/two.thtml > > <?php $javascript->link('mootoolscomp', false); ?> > <?php $javascript->codeBlock(<<<SCRIPT > window.addEvent('domready', function() { > // something here > }); > SCRIPT; > , array('inline' => false)); ?> > <h1>This page DOES have extra scripts</h1> > <p>hahaha</p> > > On Apr 17, 9:54 am, kaffe <[EMAIL PROTECTED]> wrote: > > > But I think my issue is as follows: > > > Do I really need to make an *empty* model, an *empty* database table > > and an *empty* controller - just to set the layout of a static page? > > > I have tried to take the cake page_controller and moving it to my app/ > > controllers/... but still I have this issue that I have pages that are > > mostly HTML that just need to set the layout or for instance just be > > behind a loging. > > > I am not sure if its is possible, but it would seem that making static > > pages are a bit difficult? It might be due to my ignorance... =) > > > Kind regards > > > Kristian > > > On Apr 17, 3:08 am, aranworld <[EMAIL PROTECTED]> wrote: > > > > Here is where you can get this kind of > > > answer:http://book.cakephp.org/view/94/views#layouts-96 > > > > Create two layout templates and put them in the views/layouts > > > directory. Lets say: > > > > default.ctp > > > plain_jane.ctp > > > > Now in your controller action function, add the following: > > > > $this->layout = 'default'; > > > > or > > > > $this->layout = 'plain_jane'; > > > > And either default or plain_jane will be used. > > > > On Apr 16, 11:48 am, kaffe <[EMAIL PROTECTED]> wrote: > > > > > Hi, > > > > > I am new to cake, but I have run into an annoying issue (I have spend > > > > a few days reading cakephp.org, searching google, reading the IBM turs > > > > etc). > > > > > Heres the deal I have two problems: > > > > > I am building a site that has some pages with database content that > > > > would require models and controllers; but I am also having several > > > > pages that are static - needless to say they go in: app/views/pages/ > > > > > For instance: about.thtml, faq.thtml - these pages does IMHO not need > > > > to go to the database, its only a few Kb of data and I like just doing > > > > them as plain html. > > > > > We can imagine having one layout for a page with many pictures and > > > > another for a faq that is mostly plain text and just one long column? > > > > > Issue: > > > > How do I load different app/views/layouts/ via app/views/pages/? it > > > > seems that some stuff has already rendered by the time we get to the > > > > app/views/pages/ content ... is there a workaround or proper way of > > > > doing it? > > > > > Also, we can imagine that one type of page would require the inclusion > > > > of a 60 kb Javascript in the layout whereas another page does not need > > > > to include this... > > > > > e.g. > > > > > <head> > > > > <title><?php echo $title_for_layout?></title> > > > > <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" /> > > > > <script type="text/javascript" src="scripts/mootoolscomp.js"></script> > > > > <script type="text/javascript"> > > > > > window.addEvent('domready', function() { > > > > > var Tip = new Tips($$('.Tip')); > > > > var sliders = $$(".slide"); > > > > var triggers = $$(".slide_trigger") ; > > > > > triggers.each(function( o, x ){ > > > > var sl = new Fx.Slide( sliders[x], { } > > > > ); > > > > > > > > > $(triggers[x]).addEvent('click',function(e){ > > > > e = new Event(e); > > > > sl.toggle(); > > > > e.stop(); > > > > }) > > > > sl.hide(); > > > > }); > > > > }); > > > > </script> > > > > > <?php echo $html->css('main'); ?> > > > > > </head><body> > > > > > /// versus a non js enabled page being only ///: > > > > > <head> > > > > <title><?php echo $title_for_layout?></title> > > > > <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" /> > > > > <?php echo $html->css('main'); ?> > > > > </head><body> > > > > <div id="site"> > > > > > ----------- > > > > > I am new to this so it might seem trivial, but I would really > > > > appreciate some help as I am going nuts... ;-) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" 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 -~----------~----~----~----~------~----~------~--~---