@mandar

depends on your app. Setting the site in view is simple and and short.
you can be certain which controller and action it gets applied to

the drawback is that if you want to do this in every view (as aposed to a
few)
this will become unwieldy

if you setting titles in your app ctrlr beforeRender then its very easy to
have that code
apply to controller/actions when you don't want it to - or you add a
behemoth switch/case in that function

as an example in my app I have dynamic pages (db stored pages with titles) I
apply the title in pages controller whereas
my users login (and other user views I set the title in the view)

if I did this in app ctrlr and I wanted to add new stuff I would have to
update this function and check that I get the title for corresponding
controller/actions - lots of code

whereas in views/app_users/login.ctp

<?php $this->set('title_for_layout', 'Area 51.667: Authorised Personnel
Only'); ?>

and I know that this title will only be used for the login of app_users.


it not right for all views but it is fine (and saves time) for certain
circumstances.

(perhaps wiser bakers than I will refute this claim)

 - S




On 9 June 2011 17:51, mandar <[email protected]> wrote:

> @sam
>
> Isnt view file meant for simply displaying webpages, rather than
> setting variables?
>
> I think controller is the right place for setting title for a page but
> I may be wrong
>
> any one used custom AppController had problem with setting title
> variable?
>
> thanks,
>
>
>
>
>
> On Jun 9, 4:07 pm, Sam Sherlock <[email protected]> wrote:
> > How about setting the title in the view?
> >
> >  - S
> >
> > On 9 June 2011 15:28, mandar <[email protected]> wrote:
> >
> >
> >
> >
> >
> >
> >
> > > I have already added <title><?php echo $*title_for_layout;* ?></title>
> in
> > > my layout file.
> >
> > > I guess my custom AppContoller class which (which is in root folder) is
> > > overwritiing title variable which im setting in Sites Controller
> >
> > > How do i stop AppController from overwriting title variable??
> >
> > > Any ideas?
> >
> > > thanks,
> >
> > > --
> > > Our newest site for the community: CakePHP Video Tutorials
> > >http://tv.cakephp.org
> > > Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help
> > > others with their CakePHP related questions.
> >
> > > To unsubscribe from this group, send email to
> > > [email protected] For more options, visit this
> group
> > > athttp://groups.google.com/group/cake-php
>
> --
> Our newest site for the community: CakePHP Video Tutorials
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> [email protected] For more options, visit this group
> at http://groups.google.com/group/cake-php
>

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to