Re: Newbie question for "best practice" on how to combine CakePHP with a (given) design

2010-03-31 Thread janitor048
Hey guys,

thanks a lot for these very useful hints. I will definitely do some
more reading and start experimenting along the lines of your
suggestions.
And probably come back with more specific questions then.. :-)

Cheers,
Oliver


On Mar 29, 6:05 pm, cricket  wrote:
> To add to Jeremy's comments,
>
> In your menu elements, you can refer to the present location with
> $this->here, so you can have logic for showing/hiding submenus, etc.
> and avoid having to create separate layouts for each menu situation.
>
> For my login_prompt element, I check if the user is already logged in
> like this:
>
> if (!$session->read('Auth.User'))
> {
>    // show "login" link}
>
> else
> {
>    // show "logout" and "profile" links
>
> }
>
> If your users table has an "admin" column (0 or 1) you can do if
> ($session->read('Auth.User.admin')) to test whether you should include
> admin-specific links or whatever. Note that User is uppercase, as
> that's the name of the model. In your controllers, though, you'd use
> AuthComponent's user() method: $this->Auth->user('admin').
>
> For including disparate bits of code you can place several $this->element() 
> calls and use requestAction() in the elements. Make sure
>
> you have caching enabled in core.php and specifify that you want the
> element to be cached because each requestAction() call creates an
> entirely new request through Cake, which is expensive. By caching the
> element you avoid doing that each time. See this article:
>
> http://bakery.cakephp.org/articles/view/creating-reusable-elements-wi...
>
> Or search for "cakephp requestaction cache" or similar.
>
> On Mar 29, 8:49 am, janitor048  wrote:
>
> > Hi there,
>
> > I'm pretty new to CakePHP (and MVC in general for that matter) and I'm
> > just working through the docs etc.
> > And since the cookbook is quite informative, I think I've got a pretty
> > good idea of what CakePHP could do for me by now.
>
> > However, I would like to ask a question on best or common practice on
> > how to actually integrate my pieces of cake with a given design.
> > So that I can keep these suggestions in mind when digging even deeper
> > into the documentation.
>
> > Say, I've got a webpage that features
> > - a main "view" area in the center
> > - a main menu at the top that stays constant over all pages
> > - a side menu to the left that stays constant over some pages but does
> > in general depend on the content of the central area
> > - a small side area to the right with some login / admin bits-and-
> > pieces.
>
> > Pretty common and probably pretty close to the actual project I'm
> > about to work on.
> > The general layout as described above I would like to design using
> > dreamweaver (for instance) and setting up a css formatted page using
> > divs.
>
> > The main toolbar would probably best go into a common cake layout
> > file. But what about the rest? View files with elements for left menu
> > and login-area on the right? Login stuff as an element and the left
> > menu in layout files that are selected by the controller accordingly?
>
> > Can I attach id-based css rules to a specific element created by a
> > (say) form helper? For positioning purposes and the like..
>
> > And finally: What is the best way to incorporate bits and pieces from
> > different models / controllers into a single view? That would
> > something like a summary page, e.g. showing the 5 latests news, the 3
> > latest pictures and the most popular comments (or whatever you like)
> > in different areas of a single page (as delivered to the user).
>
> > Any hints and suggestions would be highly appreciated.
> > Cheers,
> > Oliver

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

To unsubscribe, reply using "remove me" as the subject.


Re: Newbie question for "best practice" on how to combine CakePHP with a (given) design

2010-03-29 Thread cricket
To add to Jeremy's comments,

In your menu elements, you can refer to the present location with
$this->here, so you can have logic for showing/hiding submenus, etc.
and avoid having to create separate layouts for each menu situation.

For my login_prompt element, I check if the user is already logged in
like this:

if (!$session->read('Auth.User'))
{
   // show "login" link
}
else
{
   // show "logout" and "profile" links
}

If your users table has an "admin" column (0 or 1) you can do if
($session->read('Auth.User.admin')) to test whether you should include
admin-specific links or whatever. Note that User is uppercase, as
that's the name of the model. In your controllers, though, you'd use
AuthComponent's user() method: $this->Auth->user('admin').

For including disparate bits of code you can place several $this-
>element() calls and use requestAction() in the elements. Make sure
you have caching enabled in core.php and specifify that you want the
element to be cached because each requestAction() call creates an
entirely new request through Cake, which is expensive. By caching the
element you avoid doing that each time. See this article:

http://bakery.cakephp.org/articles/view/creating-reusable-elements-with-requestaction

Or search for "cakephp requestaction cache" or similar.

On Mar 29, 8:49 am, janitor048  wrote:
> Hi there,
>
> I'm pretty new to CakePHP (and MVC in general for that matter) and I'm
> just working through the docs etc.
> And since the cookbook is quite informative, I think I've got a pretty
> good idea of what CakePHP could do for me by now.
>
> However, I would like to ask a question on best or common practice on
> how to actually integrate my pieces of cake with a given design.
> So that I can keep these suggestions in mind when digging even deeper
> into the documentation.
>
> Say, I've got a webpage that features
> - a main "view" area in the center
> - a main menu at the top that stays constant over all pages
> - a side menu to the left that stays constant over some pages but does
> in general depend on the content of the central area
> - a small side area to the right with some login / admin bits-and-
> pieces.
>
> Pretty common and probably pretty close to the actual project I'm
> about to work on.
> The general layout as described above I would like to design using
> dreamweaver (for instance) and setting up a css formatted page using
> divs.
>
> The main toolbar would probably best go into a common cake layout
> file. But what about the rest? View files with elements for left menu
> and login-area on the right? Login stuff as an element and the left
> menu in layout files that are selected by the controller accordingly?
>
> Can I attach id-based css rules to a specific element created by a
> (say) form helper? For positioning purposes and the like..
>
> And finally: What is the best way to incorporate bits and pieces from
> different models / controllers into a single view? That would
> something like a summary page, e.g. showing the 5 latests news, the 3
> latest pictures and the most popular comments (or whatever you like)
> in different areas of a single page (as delivered to the user).
>
> Any hints and suggestions would be highly appreciated.
> Cheers,
> Oliver

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

To unsubscribe from this group, send email to 
cake-php+unsubscribegooglegroups.com or reply to this email with the words 
"REMOVE ME" as the subject.


Re: Newbie question for "best practice" on how to combine CakePHP with a (given) design

2010-03-29 Thread Jeremy Burns
Looks like a combination of layouts and elements. Don't forget you can create 
as many layouts as you want, and specify which one to use in your controller - 
either inside beforeFilter (so that it applies to all functions in the 
controller) or inside a controller function (which will override all other 
settings). The command is $this->layout = '*layout_name*';  '*layout_name*' can 
also be  variable, allowing you precise control.

You can customise your view at runtime by calling an element with a variable - 
echo $this->element($variable); You can also customise your elements at runtime 
by passing in variables - echo $this->element('*element_name*', 
array('variable' => 'value')); - and have your code react internally to the 
variable dynamically.

Here's a few ideas on dynamic menus: 
http://articles.classoutfit.com/2009/11/cakephp-dynamic-navigation-bars/

I'm sure there's lot of other ideas too.

Jeremy Burns
jeremybu...@me.com


On 29 Mar 2010, at 13:49, janitor048 wrote:

> Hi there,
> 
> I'm pretty new to CakePHP (and MVC in general for that matter) and I'm
> just working through the docs etc.
> And since the cookbook is quite informative, I think I've got a pretty
> good idea of what CakePHP could do for me by now.
> 
> However, I would like to ask a question on best or common practice on
> how to actually integrate my pieces of cake with a given design.
> So that I can keep these suggestions in mind when digging even deeper
> into the documentation.
> 
> Say, I've got a webpage that features
> - a main "view" area in the center
> - a main menu at the top that stays constant over all pages
> - a side menu to the left that stays constant over some pages but does
> in general depend on the content of the central area
> - a small side area to the right with some login / admin bits-and-
> pieces.
> 
> Pretty common and probably pretty close to the actual project I'm
> about to work on.
> The general layout as described above I would like to design using
> dreamweaver (for instance) and setting up a css formatted page using
> divs.
> 
> The main toolbar would probably best go into a common cake layout
> file. But what about the rest? View files with elements for left menu
> and login-area on the right? Login stuff as an element and the left
> menu in layout files that are selected by the controller accordingly?
> 
> Can I attach id-based css rules to a specific element created by a
> (say) form helper? For positioning purposes and the like..
> 
> And finally: What is the best way to incorporate bits and pieces from
> different models / controllers into a single view? That would
> something like a summary page, e.g. showing the 5 latests news, the 3
> latest pictures and the most popular comments (or whatever you like)
> in different areas of a single page (as delivered to the user).
> 
> 
> Any hints and suggestions would be highly appreciated.
> Cheers,
> Oliver
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> 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
> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
> http://groups.google.com/group/cake-php?hl=en
> 
> To unsubscribe from this group, send email to 
> cake-php+unsubscribegooglegroups.com or reply to this email with the words 
> "REMOVE ME" as the subject.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

To unsubscribe from this group, send email to 
cake-php+unsubscribegooglegroups.com or reply to this email with the words 
"REMOVE ME" as the subject.


Newbie question for "best practice" on how to combine CakePHP with a (given) design

2010-03-29 Thread janitor048
Hi there,

I'm pretty new to CakePHP (and MVC in general for that matter) and I'm
just working through the docs etc.
And since the cookbook is quite informative, I think I've got a pretty
good idea of what CakePHP could do for me by now.

However, I would like to ask a question on best or common practice on
how to actually integrate my pieces of cake with a given design.
So that I can keep these suggestions in mind when digging even deeper
into the documentation.

Say, I've got a webpage that features
- a main "view" area in the center
- a main menu at the top that stays constant over all pages
- a side menu to the left that stays constant over some pages but does
in general depend on the content of the central area
- a small side area to the right with some login / admin bits-and-
pieces.

Pretty common and probably pretty close to the actual project I'm
about to work on.
The general layout as described above I would like to design using
dreamweaver (for instance) and setting up a css formatted page using
divs.

The main toolbar would probably best go into a common cake layout
file. But what about the rest? View files with elements for left menu
and login-area on the right? Login stuff as an element and the left
menu in layout files that are selected by the controller accordingly?

Can I attach id-based css rules to a specific element created by a
(say) form helper? For positioning purposes and the like..

And finally: What is the best way to incorporate bits and pieces from
different models / controllers into a single view? That would
something like a summary page, e.g. showing the 5 latests news, the 3
latest pictures and the most popular comments (or whatever you like)
in different areas of a single page (as delivered to the user).


Any hints and suggestions would be highly appreciated.
Cheers,
Oliver

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

To unsubscribe from this group, send email to 
cake-php+unsubscribegooglegroups.com or reply to this email with the words 
"REMOVE ME" as the subject.