I'll answer b)

/app/views/layouts/default.ctp:

<html>
<head>
<title><?php echo $title_for_layout; ?></title>
</head>
<body>
<div id='header'>
header markup goes here
</div>
<div id='menu'>
menu markup goes here
</div>
<div class='content'>
<?php echo $content_for_layout; ?>
</div>
<div id='footer'>
markup for footer
</div>
</body>
</html>

> if(session) print "hello $user"
> else show login link.

That's correct :-) Why do you not think this should go in the layout?
You could paste the code into an element (note, i'm using your
pseudocode here, check out the manual on the Auth component for some
real code):

/app/views/element/session_links.ctp:

if(session) print "hello $user"
else show login link.

and in your layout:

<?php echo $this->render("session_links"); ?>


On Sep 10, 10:19 am, jkritikos <[EMAIL PROTECTED]> wrote:
> Hi there,
>
> I would like to ask 2 questions, both regarding the layout and views.
>
> a) After installing cake 1.2 and accessing my localhost domain, I get
> to see the cake info page and everything works fine. If i access a url
> that is lacking the underlying controller or view, I get to see cake's
> error message about the corresponding view file missing etc. When I
> create my own template under /app/views/layout/default.ctp, it all
> works fine but whenever I hit invalid urls (as above) nothing happens
> (i.e. i still get to see my default template but without the error
> messages). I read somewhere that by overriding the default.ctp layout
> file, you are effectively changing every page that cake would render,
> so perhaps I'm missing some variables in my layout? (e.g
> $content_for_layout, $title_for_layout etc?)
>
> b) I have been given all the templates for an application by a web
> designer. Let's say that the default layout consists of a header, a
> menu, the 'main body' and a footer. What is the correct approach for
> breaking this down in cake ? I assume that my default layout should
> contain the common elements that are always present (i.e header, menu,
> footer), and all other views will be rendered within the 'main body'
> section of the layout. However if this is the case, it would mean that
> the actual layout, in the header section should also contain code
> like:
>
> if(session) print "hello $user"
> else show login link.
>
> This somehow feels wrong. Should i have code like that in my layout ?
> What is the best practice for using a default template and some views?
>
> thanks a lot,
> jason
--~--~---------~--~----~------------~-------~--~----~
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