RE: Layout Help

2009-10-08 Thread Dave Maharaj :: WidePixels.com
Sweet!
 
Exactly the idea I was looking for.
 
Thanks,
 
Dave

  _  

From: Sam Sherlock [mailto:sam.sherl...@gmail.com] 
Sent: October-09-09 12:13 AM
To: cake-php@googlegroups.com
Subject: Re: Layout Help


You can see Hannibal Lecter's answer to the question on stackoverflow

http://stackoverflow.com/questions/1024518/cakephp-block-region 

 <http://stackoverflow.com/questions/1024518/cakephp-block-region> 

hth - S





2009/10/8 Dave Maharaj :: WidePixels.com 


I have 2 layouts crated one with a left side menu other with a right.
 
In the layout i have the standard  
which loads the view. But how can i determine what to put on the sides? 
 
The side menu modeuls can be elements, but how do I call them so i can say
on say index user login module sponsors element, and onview page use
something else?
 
Thanks,
 
 
Dave








--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Layout Help

2009-10-08 Thread Sam Sherlock
You can see Hannibal Lecter's answer to the question on stackoverflow

http://stackoverflow.com/questions/1024518/cakephp-block-region

hth - S




2009/10/8 Dave Maharaj :: WidePixels.com 

>  I have 2 layouts crated one with a left side menu other with a right.
>
> In the layout i have the standard  
> which loads the view. But how can i determine what to put on the sides?
>
> The side menu modeuls can be elements, but how do I call them so i can say
> on say index user login module sponsors element, and onview page use
> something else?
>
> Thanks,
>
>
> Dave
>
> >
>

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Layout Help

2009-10-08 Thread Dave Maharaj :: WidePixels.com
I have 2 layouts crated one with a left side menu other with a right.
 
In the layout i have the standard  
which loads the view. But how can i determine what to put on the sides? 
 
The side menu modeuls can be elements, but how do I call them so i can say
on say index user login module sponsors element, and onview page use
something else?
 
Thanks,
 
 
Dave

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Access Classes In Layout Help??

2009-10-05 Thread Bert Van den Brande
;>> wrote:
> >>>> >
> >>>> > >> Ok so I actually didn't create a layout for each view from my
> >>>> > >> controllers.
> >>>> > >> Instead, all the views use the same layout, which is the
> >>>> default.ctp.
> >>>> Is
> >>>> > >> that incorrect? From my understanding, the default layout is
> >>>> loaded
> >>>> by
> >>>> > >> every
> >>>> > >> view and that's why I have my navigation bar in it.  It seems
> that
> >>>> I
> >>>> can
> >>>> > >> only access those "set" variables from something like
> >>>> > >> views/layouts/cars/index.ctp but not views/layouts/default.ctp.
> Is
> >>>> there
> >>>> > >> a
> >>>> > >> difference between the model layouts and the default layout?
> >>>> >
> >>>> > > You *almost* have it. Once again:
> >>>> >
> >>>> > > When a controller's action is run, its render() method is called
> >>>> > > automatically (yes, you can call it yourself but please ignore
> that
> >>>> > > for now). When that happens, Cake will use the View class to
> render
> >>>> > > the view template for that action. These templates are in
> >>>> > > app/views/controller_name_ending_in_s/action_name.ctp
> >>>> >
> >>>> > > Usually, the view template contains some HTML that you have
> >>>> included,
> >>>> > > along with some variables. Those variables are passed to the View
> >>>> > > class through the controller's $viewVars class variable. When you
> >>>> call
> >>>> > > $this->set('foo', 'bar'), you are passing the value, 'bar' to the
> >>>> > > controller's $viewVars array with a key, 'foo'.
> >>>> >
> >>>> > > When the controller's $viewVars is handed off to the View class,
> it
> >>>> > > extracts them, essentially creating a var named $foo that contains
> >>>> the
> >>>> > > value 'bar'.
> >>>> >
> >>>> > > Now, after the View has finished using the view template to render
> >>>> > > something to output it creates a variable called,
> >>>> $content_for_layout.
> >>>> >
> >>>> > > It then renders the layout template. That's a file in
> >>>> > > app/views/layout/name_of_your_layout.ctp. If you don't specify a
> >>>> > > layout, Cake uses 'default'.
> >>>> >
> >>>> > > Inside the layout template is (should be) a variable named ...
> >>>> > > $content_for_layout. This is where the contents of your rendered
> >>>> view
> >>>> > > are written to the layout.
> >>>> >
> >>>> > > So, try this: In one of your controller actions, add
> >>>> $this->set('foo',
> >>>> > > 'bar');
> >>>> >
> >>>> > > In your app/views/layouts/default.ctp add this, just above
> >>>> > > $content_for_layout
> >>>> >
> >>>> > > echo $foo;
> >>>> >
> >>>> > > You should see 'bar' in there, somewhere. View source and search
> >>>> for
> >>>> > > it, because your CSS may hide it.
> >>>> >
> >>>> > > Anyway, perhaps you should post the relevant part of your layout
> >>>> file
> >>>> > > and the controller action.
> >>>> >
> >>>> > --
> >>>> > View this message in context:
> >>>>
> http://www.nabble.com/Access-Classes-In-Layout-Help---tp25706283p2572...
> >>>> > Sent from the CakePHP mailing list archive at Nabble.com.
> >>>> >
> >>>>
> >>>
> >>> >
> >>>
> >>>
> >>
> >> --
> >> View this message in context:
> >>
> http://www.nabble.com/Access-Classes-In-Layout-Help---tp25706283p25731765.html
> >> Sent from the CakePHP mailing list archive at Nabble.com.
> >>
> >>
> >> >
> >>
> >
> > >
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Access-Classes-In-Layout-Help---tp25706283p25757183.html
> Sent from the CakePHP mailing list archive at Nabble.com.
>
>
> >
>

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Access Classes In Layout Help??

2009-10-05 Thread hahmadi82
ot views/layouts/default.ctp. Is
>>>> there
>>>> > >> a
>>>> > >> difference between the model layouts and the default layout?
>>>> >
>>>> > > You *almost* have it. Once again:
>>>> >
>>>> > > When a controller's action is run, its render() method is called
>>>> > > automatically (yes, you can call it yourself but please ignore that
>>>> > > for now). When that happens, Cake will use the View class to render
>>>> > > the view template for that action. These templates are in
>>>> > > app/views/controller_name_ending_in_s/action_name.ctp
>>>> >
>>>> > > Usually, the view template contains some HTML that you have
>>>> included,
>>>> > > along with some variables. Those variables are passed to the View
>>>> > > class through the controller's $viewVars class variable. When you
>>>> call
>>>> > > $this->set('foo', 'bar'), you are passing the value, 'bar' to the
>>>> > > controller's $viewVars array with a key, 'foo'.
>>>> >
>>>> > > When the controller's $viewVars is handed off to the View class, it
>>>> > > extracts them, essentially creating a var named $foo that contains
>>>> the
>>>> > > value 'bar'.
>>>> >
>>>> > > Now, after the View has finished using the view template to render
>>>> > > something to output it creates a variable called,
>>>> $content_for_layout.
>>>> >
>>>> > > It then renders the layout template. That's a file in
>>>> > > app/views/layout/name_of_your_layout.ctp. If you don't specify a
>>>> > > layout, Cake uses 'default'.
>>>> >
>>>> > > Inside the layout template is (should be) a variable named ...
>>>> > > $content_for_layout. This is where the contents of your rendered
>>>> view
>>>> > > are written to the layout.
>>>> >
>>>> > > So, try this: In one of your controller actions, add
>>>> $this->set('foo',
>>>> > > 'bar');
>>>> >
>>>> > > In your app/views/layouts/default.ctp add this, just above
>>>> > > $content_for_layout
>>>> >
>>>> > > echo $foo;
>>>> >
>>>> > > You should see 'bar' in there, somewhere. View source and search
>>>> for
>>>> > > it, because your CSS may hide it.
>>>> >
>>>> > > Anyway, perhaps you should post the relevant part of your layout
>>>> file
>>>> > > and the controller action.
>>>> >
>>>> > --
>>>> > View this message in context:
>>>> http://www.nabble.com/Access-Classes-In-Layout-Help---tp25706283p2572...
>>>> > Sent from the CakePHP mailing list archive at Nabble.com.
>>>> >
>>>>
>>>
>>> >
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Access-Classes-In-Layout-Help---tp25706283p25731765.html
>> Sent from the CakePHP mailing list archive at Nabble.com.
>>
>>
>> >
>>
> 
> > 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Access-Classes-In-Layout-Help---tp25706283p25757183.html
Sent from the CakePHP mailing list archive at Nabble.com.


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Access Classes In Layout Help??

2009-10-05 Thread hahmadi82
 model layouts and the default layout?
>>>> >
>>>> > > You *almost* have it. Once again:
>>>> >
>>>> > > When a controller's action is run, its render() method is called
>>>> > > automatically (yes, you can call it yourself but please ignore that
>>>> > > for now). When that happens, Cake will use the View class to render
>>>> > > the view template for that action. These templates are in
>>>> > > app/views/controller_name_ending_in_s/action_name.ctp
>>>> >
>>>> > > Usually, the view template contains some HTML that you have
>>>> included,
>>>> > > along with some variables. Those variables are passed to the View
>>>> > > class through the controller's $viewVars class variable. When you
>>>> call
>>>> > > $this->set('foo', 'bar'), you are passing the value, 'bar' to the
>>>> > > controller's $viewVars array with a key, 'foo'.
>>>> >
>>>> > > When the controller's $viewVars is handed off to the View class, it
>>>> > > extracts them, essentially creating a var named $foo that contains
>>>> the
>>>> > > value 'bar'.
>>>> >
>>>> > > Now, after the View has finished using the view template to render
>>>> > > something to output it creates a variable called,
>>>> $content_for_layout.
>>>> >
>>>> > > It then renders the layout template. That's a file in
>>>> > > app/views/layout/name_of_your_layout.ctp. If you don't specify a
>>>> > > layout, Cake uses 'default'.
>>>> >
>>>> > > Inside the layout template is (should be) a variable named ...
>>>> > > $content_for_layout. This is where the contents of your rendered
>>>> view
>>>> > > are written to the layout.
>>>> >
>>>> > > So, try this: In one of your controller actions, add
>>>> $this->set('foo',
>>>> > > 'bar');
>>>> >
>>>> > > In your app/views/layouts/default.ctp add this, just above
>>>> > > $content_for_layout
>>>> >
>>>> > > echo $foo;
>>>> >
>>>> > > You should see 'bar' in there, somewhere. View source and search
>>>> for
>>>> > > it, because your CSS may hide it.
>>>> >
>>>> > > Anyway, perhaps you should post the relevant part of your layout
>>>> file
>>>> > > and the controller action.
>>>> >
>>>> > --
>>>> > View this message in context:
>>>> http://www.nabble.com/Access-Classes-In-Layout-Help---tp25706283p2572...
>>>> > Sent from the CakePHP mailing list archive at Nabble.com.
>>>> >
>>>>
>>>
>>> >
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Access-Classes-In-Layout-Help---tp25706283p25731765.html
>> Sent from the CakePHP mailing list archive at Nabble.com.
>>
>>
>> >
>>
> 
> > 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Access-Classes-In-Layout-Help---tp25706283p25757010.html
Sent from the CakePHP mailing list archive at Nabble.com.


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Access Classes In Layout Help??

2009-10-03 Thread brian
'bar'), you are passing the value, 'bar' to the
>>> > > controller's $viewVars array with a key, 'foo'.
>>> >
>>> > > When the controller's $viewVars is handed off to the View class, it
>>> > > extracts them, essentially creating a var named $foo that contains
>>> the
>>> > > value 'bar'.
>>> >
>>> > > Now, after the View has finished using the view template to render
>>> > > something to output it creates a variable called,
>>> $content_for_layout.
>>> >
>>> > > It then renders the layout template. That's a file in
>>> > > app/views/layout/name_of_your_layout.ctp. If you don't specify a
>>> > > layout, Cake uses 'default'.
>>> >
>>> > > Inside the layout template is (should be) a variable named ...
>>> > > $content_for_layout. This is where the contents of your rendered view
>>> > > are written to the layout.
>>> >
>>> > > So, try this: In one of your controller actions, add
>>> $this->set('foo',
>>> > > 'bar');
>>> >
>>> > > In your app/views/layouts/default.ctp add this, just above
>>> > > $content_for_layout
>>> >
>>> > > echo $foo;
>>> >
>>> > > You should see 'bar' in there, somewhere. View source and search for
>>> > > it, because your CSS may hide it.
>>> >
>>> > > Anyway, perhaps you should post the relevant part of your layout file
>>> > > and the controller action.
>>> >
>>> > --
>>> > View this message in context:
>>> http://www.nabble.com/Access-Classes-In-Layout-Help---tp25706283p2572...
>>> > Sent from the CakePHP mailing list archive at Nabble.com.
>>> >
>>>
>>
>> >
>>
>>
>
> --
> View this message in context: 
> http://www.nabble.com/Access-Classes-In-Layout-Help---tp25706283p25731765.html
> Sent from the CakePHP mailing list archive at Nabble.com.
>
>
> >
>

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Access Classes In Layout Help??

2009-10-03 Thread hahmadi82


Yea, probably much easier for me to explain what I've done and what I'd like
to do.

So basically I implemented the ajax select box using the code below:

http://www.devmoz.com/blog/2007/04/04/cakephp-update-a-select-box-using-ajax/

My code set up is more less the same as the example posted in that article. 
The ajax select box I created allows a user to select a car make, then year,
then model.  Currently, I have this working in index.ctp just like the
example, and the ajax calls the update_select.ctp.

What I would like to do, is move this ajax selector into my navigation bar
so that the user can change is car at any point during his browsing
experience.  This means that no matter what view he's on, he can still use
my ajax selector through the navbar.

The complication is that my code is in my car_controller "index.ctp" and
uses "update_select.ctp" with observefield (like the example).  I want to
somehow move this code/functionality into my default.ctp.  Perhaps you guys
can suggest the best strategy?  Even if I move the code from index.ctp to
default and access the set variable from the app_controller before filter
(as suggested), I still have the issue of ajax having to call the
update_select function which I have no idea where I would move it to
(perhaps in the app_controller?)...

I apologize for the constant questions and greatly appreciate the help you
guys have been giving me :)  





And then we scroll back 15 emails :


If this works, then I would suggest to add your layout data to the view
inside the beforeFilter() method of AppController and then use this data in
your layout. Might even consider creating an element for the part that uses
this data ...


> 
> :)
> 
> On Sat, Oct 3, 2009 at 10:34 AM, Miles J  wrote:
> 
>>
>> Do it in the beforeFilter() of your AppController, that will apply it
>> to all views and layouts.
>>
>> On Oct 3, 1:18 am, hahmadi82  wrote:
>> > Now I see!  So the set variables change depending on which view is
>> showing
>> > within the default.ctp.  If I add this car action to the app_controller
>> > (instead of car model) and set the variables there, will all the views
>> have
>> > access to that variable? How can I make a global "set" variable that
>> comes
>> > from a specific query?
>> >
>> >
>> >
>> > brian-263 wrote:
>> >
>> > > On Fri, Oct 2, 2009 at 10:55 PM, hahmadi82 
>> wrote:
>> >
>> > >> Ok so I actually didn't create a layout for each view from my
>> > >> controllers.
>> > >> Instead, all the views use the same layout, which is the
>> default.ctp.
>> Is
>> > >> that incorrect? From my understanding, the default layout is loaded
>> by
>> > >> every
>> > >> view and that's why I have my navigation bar in it.  It seems that I
>> can
>> > >> only access those "set" variables from something like
>> > >> views/layouts/cars/index.ctp but not views/layouts/default.ctp. Is
>> there
>> > >> a
>> > >> difference between the model layouts and the default layout?
>> >
>> > > You *almost* have it. Once again:
>> >
>> > > When a controller's action is run, its render() method is called
>> > > automatically (yes, you can call it yourself but please ignore that
>> > > for now). When that happens, Cake will use the View class to render
>> > > the view template for that action. These templates are in
>> > > app/views/controller_name_ending_in_s/action_name.ctp
>> >
>> > > Usually, the view template contains some HTML that you have included,
>> > > along with some variables. Those variables are passed to the View
>> > > class through the controller's $viewVars class variable. When you
>> call
>> > > $this->set('foo', 'bar'), you are passing the value, 'bar' to the
>> > > controller's $viewVars array with a key, 'foo'.
>> >
>> > > When the controller's $viewVars is handed off to the View class, it
>> > > extracts them, essentially creating a var named $foo that contains
>> the
>> > > value 'bar'.
>> >
>> > > Now, after the View has finished using the view template to render
>> > > something to output it creates a variable called,
>> $content_for_layout.
>> >
>> > > It then renders the layout template. That's a file in
>> > > app/views/layout/name_of_your_layout.ctp. If you don'

Re: Access Classes In Layout Help??

2009-10-03 Thread Bert Van den Brande
And then we scroll back 15 emails :


If this works, then I would suggest to add your layout data to the view
inside the beforeFilter() method of AppController and then use this data in
your layout. Might even consider creating an element for the part that uses
this data ...


:)

On Sat, Oct 3, 2009 at 10:34 AM, Miles J  wrote:

>
> Do it in the beforeFilter() of your AppController, that will apply it
> to all views and layouts.
>
> On Oct 3, 1:18 am, hahmadi82  wrote:
> > Now I see!  So the set variables change depending on which view is
> showing
> > within the default.ctp.  If I add this car action to the app_controller
> > (instead of car model) and set the variables there, will all the views
> have
> > access to that variable? How can I make a global "set" variable that
> comes
> > from a specific query?
> >
> >
> >
> > brian-263 wrote:
> >
> > > On Fri, Oct 2, 2009 at 10:55 PM, hahmadi82 
> wrote:
> >
> > >> Ok so I actually didn't create a layout for each view from my
> > >> controllers.
> > >> Instead, all the views use the same layout, which is the default.ctp.
> Is
> > >> that incorrect? From my understanding, the default layout is loaded by
> > >> every
> > >> view and that's why I have my navigation bar in it.  It seems that I
> can
> > >> only access those "set" variables from something like
> > >> views/layouts/cars/index.ctp but not views/layouts/default.ctp. Is
> there
> > >> a
> > >> difference between the model layouts and the default layout?
> >
> > > You *almost* have it. Once again:
> >
> > > When a controller's action is run, its render() method is called
> > > automatically (yes, you can call it yourself but please ignore that
> > > for now). When that happens, Cake will use the View class to render
> > > the view template for that action. These templates are in
> > > app/views/controller_name_ending_in_s/action_name.ctp
> >
> > > Usually, the view template contains some HTML that you have included,
> > > along with some variables. Those variables are passed to the View
> > > class through the controller's $viewVars class variable. When you call
> > > $this->set('foo', 'bar'), you are passing the value, 'bar' to the
> > > controller's $viewVars array with a key, 'foo'.
> >
> > > When the controller's $viewVars is handed off to the View class, it
> > > extracts them, essentially creating a var named $foo that contains the
> > > value 'bar'.
> >
> > > Now, after the View has finished using the view template to render
> > > something to output it creates a variable called, $content_for_layout.
> >
> > > It then renders the layout template. That's a file in
> > > app/views/layout/name_of_your_layout.ctp. If you don't specify a
> > > layout, Cake uses 'default'.
> >
> > > Inside the layout template is (should be) a variable named ...
> > > $content_for_layout. This is where the contents of your rendered view
> > > are written to the layout.
> >
> > > So, try this: In one of your controller actions, add $this->set('foo',
> > > 'bar');
> >
> > > In your app/views/layouts/default.ctp add this, just above
> > > $content_for_layout
> >
> > > echo $foo;
> >
> > > You should see 'bar' in there, somewhere. View source and search for
> > > it, because your CSS may hide it.
> >
> > > Anyway, perhaps you should post the relevant part of your layout file
> > > and the controller action.
> >
> > --
> > View this message in context:
> http://www.nabble.com/Access-Classes-In-Layout-Help---tp25706283p2572...
> > Sent from the CakePHP mailing list archive at Nabble.com.
> >
>

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Access Classes In Layout Help??

2009-10-03 Thread brian

On Sat, Oct 3, 2009 at 4:18 AM, hahmadi82  wrote:
>
>
> Now I see!  So the set variables change depending on which view is showing
> within the default.ctp.  If I add this car action to the app_controller
> (instead of car model) and set the variables there, will all the views have
> access to that variable? How can I make a global "set" variable that comes
> from a specific query?

I think you're still not quite seeing it. But I'm having some
difficulty understanding what it is you're trying to do. Maybe you
should post some code.

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Access Classes In Layout Help??

2009-10-03 Thread Miles J

Do it in the beforeFilter() of your AppController, that will apply it
to all views and layouts.

On Oct 3, 1:18 am, hahmadi82  wrote:
> Now I see!  So the set variables change depending on which view is showing
> within the default.ctp.  If I add this car action to the app_controller
> (instead of car model) and set the variables there, will all the views have
> access to that variable? How can I make a global "set" variable that comes
> from a specific query?
>
>
>
> brian-263 wrote:
>
> > On Fri, Oct 2, 2009 at 10:55 PM, hahmadi82  wrote:
>
> >> Ok so I actually didn't create a layout for each view from my
> >> controllers.
> >> Instead, all the views use the same layout, which is the default.ctp. Is
> >> that incorrect? From my understanding, the default layout is loaded by
> >> every
> >> view and that's why I have my navigation bar in it.  It seems that I can
> >> only access those "set" variables from something like
> >> views/layouts/cars/index.ctp but not views/layouts/default.ctp. Is there
> >> a
> >> difference between the model layouts and the default layout?
>
> > You *almost* have it. Once again:
>
> > When a controller's action is run, its render() method is called
> > automatically (yes, you can call it yourself but please ignore that
> > for now). When that happens, Cake will use the View class to render
> > the view template for that action. These templates are in
> > app/views/controller_name_ending_in_s/action_name.ctp
>
> > Usually, the view template contains some HTML that you have included,
> > along with some variables. Those variables are passed to the View
> > class through the controller's $viewVars class variable. When you call
> > $this->set('foo', 'bar'), you are passing the value, 'bar' to the
> > controller's $viewVars array with a key, 'foo'.
>
> > When the controller's $viewVars is handed off to the View class, it
> > extracts them, essentially creating a var named $foo that contains the
> > value 'bar'.
>
> > Now, after the View has finished using the view template to render
> > something to output it creates a variable called, $content_for_layout.
>
> > It then renders the layout template. That's a file in
> > app/views/layout/name_of_your_layout.ctp. If you don't specify a
> > layout, Cake uses 'default'.
>
> > Inside the layout template is (should be) a variable named ...
> > $content_for_layout. This is where the contents of your rendered view
> > are written to the layout.
>
> > So, try this: In one of your controller actions, add $this->set('foo',
> > 'bar');
>
> > In your app/views/layouts/default.ctp add this, just above
> > $content_for_layout
>
> > echo $foo;
>
> > You should see 'bar' in there, somewhere. View source and search for
> > it, because your CSS may hide it.
>
> > Anyway, perhaps you should post the relevant part of your layout file
> > and the controller action.
>
> --
> View this message in 
> context:http://www.nabble.com/Access-Classes-In-Layout-Help---tp25706283p2572...
> Sent from the CakePHP mailing list archive at Nabble.com.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Access Classes In Layout Help??

2009-10-03 Thread hahmadi82


Now I see!  So the set variables change depending on which view is showing
within the default.ctp.  If I add this car action to the app_controller
(instead of car model) and set the variables there, will all the views have
access to that variable? How can I make a global "set" variable that comes
from a specific query?

 

brian-263 wrote:
> 
> 
> On Fri, Oct 2, 2009 at 10:55 PM, hahmadi82  wrote:
>>
>>
>> Ok so I actually didn't create a layout for each view from my
>> controllers.
>> Instead, all the views use the same layout, which is the default.ctp. Is
>> that incorrect? From my understanding, the default layout is loaded by
>> every
>> view and that's why I have my navigation bar in it.  It seems that I can
>> only access those "set" variables from something like
>> views/layouts/cars/index.ctp but not views/layouts/default.ctp. Is there
>> a
>> difference between the model layouts and the default layout?
> 
> You *almost* have it. Once again:
> 
> When a controller's action is run, its render() method is called
> automatically (yes, you can call it yourself but please ignore that
> for now). When that happens, Cake will use the View class to render
> the view template for that action. These templates are in
> app/views/controller_name_ending_in_s/action_name.ctp
> 
> Usually, the view template contains some HTML that you have included,
> along with some variables. Those variables are passed to the View
> class through the controller's $viewVars class variable. When you call
> $this->set('foo', 'bar'), you are passing the value, 'bar' to the
> controller's $viewVars array with a key, 'foo'.
> 
> When the controller's $viewVars is handed off to the View class, it
> extracts them, essentially creating a var named $foo that contains the
> value 'bar'.
> 
> Now, after the View has finished using the view template to render
> something to output it creates a variable called, $content_for_layout.
> 
> It then renders the layout template. That's a file in
> app/views/layout/name_of_your_layout.ctp. If you don't specify a
> layout, Cake uses 'default'.
> 
> Inside the layout template is (should be) a variable named ...
> $content_for_layout. This is where the contents of your rendered view
> are written to the layout.
> 
> So, try this: In one of your controller actions, add $this->set('foo',
> 'bar');
> 
> In your app/views/layouts/default.ctp add this, just above
> $content_for_layout
> 
> echo $foo;
> 
> You should see 'bar' in there, somewhere. View source and search for
> it, because your CSS may hide it.
> 
> Anyway, perhaps you should post the relevant part of your layout file
> and the controller action.
> 
> > 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Access-Classes-In-Layout-Help---tp25706283p25726631.html
Sent from the CakePHP mailing list archive at Nabble.com.


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Access Classes In Layout Help??

2009-10-02 Thread brian

On Fri, Oct 2, 2009 at 10:55 PM, hahmadi82  wrote:
>
>
> Ok so I actually didn't create a layout for each view from my controllers.
> Instead, all the views use the same layout, which is the default.ctp. Is
> that incorrect? From my understanding, the default layout is loaded by every
> view and that's why I have my navigation bar in it.  It seems that I can
> only access those "set" variables from something like
> views/layouts/cars/index.ctp but not views/layouts/default.ctp. Is there a
> difference between the model layouts and the default layout?

You *almost* have it. Once again:

When a controller's action is run, its render() method is called
automatically (yes, you can call it yourself but please ignore that
for now). When that happens, Cake will use the View class to render
the view template for that action. These templates are in
app/views/controller_name_ending_in_s/action_name.ctp

Usually, the view template contains some HTML that you have included,
along with some variables. Those variables are passed to the View
class through the controller's $viewVars class variable. When you call
$this->set('foo', 'bar'), you are passing the value, 'bar' to the
controller's $viewVars array with a key, 'foo'.

When the controller's $viewVars is handed off to the View class, it
extracts them, essentially creating a var named $foo that contains the
value 'bar'.

Now, after the View has finished using the view template to render
something to output it creates a variable called, $content_for_layout.

It then renders the layout template. That's a file in
app/views/layout/name_of_your_layout.ctp. If you don't specify a
layout, Cake uses 'default'.

Inside the layout template is (should be) a variable named ...
$content_for_layout. This is where the contents of your rendered view
are written to the layout.

So, try this: In one of your controller actions, add $this->set('foo', 'bar');

In your app/views/layouts/default.ctp add this, just above $content_for_layout

echo $foo;

You should see 'bar' in there, somewhere. View source and search for
it, because your CSS may hide it.

Anyway, perhaps you should post the relevant part of your layout file
and the controller action.

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Access Classes In Layout Help??

2009-10-02 Thread hahmadi82


Ok so I actually didn't create a layout for each view from my controllers. 
Instead, all the views use the same layout, which is the default.ctp. Is
that incorrect? From my understanding, the default layout is loaded by every
view and that's why I have my navigation bar in it.  It seems that I can
only access those "set" variables from something like
views/layouts/cars/index.ctp but not views/layouts/default.ctp. Is there a
difference between the model layouts and the default layout?


Miles J wrote:
> 
> 
> Thats what "layouts" are far. They are the wrappers/containers of all
> your views. The layouts should include the headers/footers or your
> HTML as well as the HTML html, head and body tags. Your view should be
> generated within the body of your layout.
> 
> Any data passed to the view will be accessible in the layout.
> 
> No matter what is passed with set(), your layout can access it. If you
> want more usage, try using $this in your layout/view.
> 
> Do a debug($this) in your view to see what parameters you can work
> with.
> 
> On Oct 2, 3:27 pm, hahmadi82  wrote:
>> I'm not talking about passing variables to  the view for that controller.
>> All
>> my views are set up perfectly for every controller.  For my cars class I
>> have a car controller and a views/cars/index.ctp etc which utilizes
>> all
>> the set variables from car_controller.php actions.  This is not an issue
>> for
>> me.
>>
>> The problem is that my webpage toolbar that shows on every page is set up
>> in
>> the view/layout/default.ctp.  However the default.ctp is not associated
>> to
>> any controller so I am not able to access any data from the other
>> controllers.  the default.ctp is weird to me because it also doesn't have
>> it's own controller or model.  So I also can't pull data from other
>> models.
>> All I use the default.ctp for is to have my "Home" "Profile" "Login"
>> "Logout" "Register" buttons which are just $html->link
>> (controller/action).
>> What I want to include in this tool bar is some data from my car class,
>> but
>> I can't figure out how
>>
>>
>>
>> Miles J wrote:
>>
>> > No yours till doing it wrong. You do not need to call render() unless
>> > you want to call a different .ctp file that does not associate with
>> > the current action.
>>
>> > To set/pass data to the view just use the set() method.
>>
>> > $this->set('v', $var);
>>
>> > Then in your view just use it:
>>
>> > echo $v;
>>
>> --
>> View this message in
>> context:http://www.nabble.com/Access-Classes-In-Layout-Help---tp25706283p2572...
>> Sent from the CakePHP mailing list archive at Nabble.com.
> > 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Access-Classes-In-Layout-Help---tp25706283p25725300.html
Sent from the CakePHP mailing list archive at Nabble.com.


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Access Classes In Layout Help??

2009-10-02 Thread Miles J

Thats what "layouts" are far. They are the wrappers/containers of all
your views. The layouts should include the headers/footers or your
HTML as well as the HTML html, head and body tags. Your view should be
generated within the body of your layout.

Any data passed to the view will be accessible in the layout.

No matter what is passed with set(), your layout can access it. If you
want more usage, try using $this in your layout/view.

Do a debug($this) in your view to see what parameters you can work
with.

On Oct 2, 3:27 pm, hahmadi82  wrote:
> I'm not talking about passing variables to  the view for that controller. All
> my views are set up perfectly for every controller.  For my cars class I
> have a car controller and a views/cars/index.ctp etc which utilizes all
> the set variables from car_controller.php actions.  This is not an issue for
> me.
>
> The problem is that my webpage toolbar that shows on every page is set up in
> the view/layout/default.ctp.  However the default.ctp is not associated to
> any controller so I am not able to access any data from the other
> controllers.  the default.ctp is weird to me because it also doesn't have
> it's own controller or model.  So I also can't pull data from other models.
> All I use the default.ctp for is to have my "Home" "Profile" "Login"
> "Logout" "Register" buttons which are just $html->link (controller/action).
> What I want to include in this tool bar is some data from my car class, but
> I can't figure out how
>
>
>
> Miles J wrote:
>
> > No yours till doing it wrong. You do not need to call render() unless
> > you want to call a different .ctp file that does not associate with
> > the current action.
>
> > To set/pass data to the view just use the set() method.
>
> > $this->set('v', $var);
>
> > Then in your view just use it:
>
> > echo $v;
>
> --
> View this message in 
> context:http://www.nabble.com/Access-Classes-In-Layout-Help---tp25706283p2572...
> Sent from the CakePHP mailing list archive at Nabble.com.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Access Classes In Layout Help??

2009-10-02 Thread hahmadi82


I'm not talking about passing variables to  the view for that controller. All
my views are set up perfectly for every controller.  For my cars class I
have a car controller and a views/cars/index.ctp etc which utilizes all
the set variables from car_controller.php actions.  This is not an issue for
me.

The problem is that my webpage toolbar that shows on every page is set up in
the view/layout/default.ctp.  However the default.ctp is not associated to
any controller so I am not able to access any data from the other
controllers.  the default.ctp is weird to me because it also doesn't have
it's own controller or model.  So I also can't pull data from other models. 
All I use the default.ctp for is to have my "Home" "Profile" "Login"
"Logout" "Register" buttons which are just $html->link (controller/action). 
What I want to include in this tool bar is some data from my car class, but
I can't figure out how


Miles J wrote:
> 
> 
> No yours till doing it wrong. You do not need to call render() unless
> you want to call a different .ctp file that does not associate with
> the current action.
> 
> To set/pass data to the view just use the set() method.
> 
> $this->set('v', $var);
> 
> Then in your view just use it:
> 
> echo $v;
> > 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Access-Classes-In-Layout-Help---tp25706283p25723661.html
Sent from the CakePHP mailing list archive at Nabble.com.


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Access Classes In Layout Help??

2009-10-02 Thread Miles J

No yours till doing it wrong. You do not need to call render() unless
you want to call a different .ctp file that does not associate with
the current action.

To set/pass data to the view just use the set() method.

$this->set('v', $var);

Then in your view just use it:

echo $v;
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Access Classes In Layout Help??

2009-10-02 Thread hahmadi82


My issue with the cake site is it never gives a thorough description on
anything.  It's why I'm always on nabble asking silly questions :P From what
I read from the link you provided, it seems I need to do something with the
$this->render function. 

The set variables I've already defined do not automatically show up in my
layout/view/default.ctp as the posts above implied.  Where can I call the
render function to properly direct my variables to the layout.  Do put in
the controller action:

$this->render(null, 'layout');

Will that send all that actions set variables to the layout?  Or is there
something I need to call in default.ctp to get that information. 
Unfortunately, I'm still confused about this...


Miles J wrote:
> 
> 
> Perhaps you should read the documentation before proceeding any
> further.
> 
> http://book.cakephp.org/view/57/Controller-Methods
> 
> On Oct 2, 4:11 am, Bert Van den Brande  wrote:
>> Calling $this->set('someInformation', 'someValue') in the controller will
>> make the var $someInformation available in both the view and the layout
>> ...
>> I think :)
>>
>> On Fri, Oct 2, 2009 at 10:08 AM, hahmadi82  wrote:
>>
>> > I'm not sure I follow.  How do I pass the information into the layout
>> file?
>>
>> > Miles J wrote:
>>
>> > > Just put  in your layout file, and
>> > > then Cake will render your controllers view within that variables
>> > > location.
>>
>> > > On Oct 1, 3:05 pm, hahmadi82  wrote:
>> > >> Correct, I want to use stuff from my cars controller in the
>> > >> views/layout/default.ctp.  The only possible solution I can think is
>> to
>> > >> use
>> > >> ajax to load some of the car stuff.  Basically, I'm curious how you
>> can
>> > >> access your database from the layout file.
>>
>> > >> Miles J wrote:
>>
>> > >> > Im sorry but I dont understand what you are asking.
>>
>> > >> > Layout toolbar? Controller class? Do you mean component?
>>
>> > >> > Layout has no controller? Not sure what you mean there.
>>
>> > >> > Database in layout? You mean your result right?
>>
>> > >> > On Oct 1, 1:52 pm, hahmadi82  wrote:
>> > >> >> Hi,
>>
>> > >> >> I built a class with controller/views that I want displayed in my
>> > >> layout
>> > >> >> toolbar.  Is this possible?  How can I use this queried data in
>> my
>> > >> layout
>> > >> >> file?  Since layout has no controller, I'm not sure how I can use
>> any
>> > >> >> database stuff in the layout
>> > >> >> --
>> > >> >> View this message in
>>
>> > >> context:
>> >http://www.nabble.com/Access-Classes-In-Layout-Help---tp25706283p2570...
>> > >> >> Sent from the CakePHP mailing list archive at Nabble.com.
>>
>> > >> --
>> > >> View this message in
>> > >> context:
>> >http://www.nabble.com/Access-Classes-In-Layout-Help---tp25706283p2570...
>> > >> Sent from the CakePHP mailing list archive at Nabble.com.
>>
>> > --
>> > View this message in context:
>> >http://www.nabble.com/Access-Classes-In-Layout-Help---tp25706283p2571...
>> > Sent from the CakePHP mailing list archive at Nabble.com.
> > 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Access-Classes-In-Layout-Help---tp25706283p25722068.html
Sent from the CakePHP mailing list archive at Nabble.com.


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Access Classes In Layout Help??

2009-10-02 Thread Miles J

Perhaps you should read the documentation before proceeding any
further.

http://book.cakephp.org/view/57/Controller-Methods

On Oct 2, 4:11 am, Bert Van den Brande  wrote:
> Calling $this->set('someInformation', 'someValue') in the controller will
> make the var $someInformation available in both the view and the layout ...
> I think :)
>
> On Fri, Oct 2, 2009 at 10:08 AM, hahmadi82  wrote:
>
> > I'm not sure I follow.  How do I pass the information into the layout file?
>
> > Miles J wrote:
>
> > > Just put  in your layout file, and
> > > then Cake will render your controllers view within that variables
> > > location.
>
> > > On Oct 1, 3:05 pm, hahmadi82  wrote:
> > >> Correct, I want to use stuff from my cars controller in the
> > >> views/layout/default.ctp.  The only possible solution I can think is to
> > >> use
> > >> ajax to load some of the car stuff.  Basically, I'm curious how you can
> > >> access your database from the layout file.
>
> > >> Miles J wrote:
>
> > >> > Im sorry but I dont understand what you are asking.
>
> > >> > Layout toolbar? Controller class? Do you mean component?
>
> > >> > Layout has no controller? Not sure what you mean there.
>
> > >> > Database in layout? You mean your result right?
>
> > >> > On Oct 1, 1:52 pm, hahmadi82  wrote:
> > >> >> Hi,
>
> > >> >> I built a class with controller/views that I want displayed in my
> > >> layout
> > >> >> toolbar.  Is this possible?  How can I use this queried data in my
> > >> layout
> > >> >> file?  Since layout has no controller, I'm not sure how I can use any
> > >> >> database stuff in the layout
> > >> >> --
> > >> >> View this message in
>
> > >> context:
> >http://www.nabble.com/Access-Classes-In-Layout-Help---tp25706283p2570...
> > >> >> Sent from the CakePHP mailing list archive at Nabble.com.
>
> > >> --
> > >> View this message in
> > >> context:
> >http://www.nabble.com/Access-Classes-In-Layout-Help---tp25706283p2570...
> > >> Sent from the CakePHP mailing list archive at Nabble.com.
>
> > --
> > View this message in context:
> >http://www.nabble.com/Access-Classes-In-Layout-Help---tp25706283p2571...
> > Sent from the CakePHP mailing list archive at Nabble.com.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Access Classes In Layout Help??

2009-10-02 Thread Bert Van den Brande
Calling $this->set('someInformation', 'someValue') in the controller will
make the var $someInformation available in both the view and the layout ...
I think :)

On Fri, Oct 2, 2009 at 10:08 AM, hahmadi82  wrote:

>
>
> I'm not sure I follow.  How do I pass the information into the layout file?
>
> Miles J wrote:
> >
> >
> > Just put  in your layout file, and
> > then Cake will render your controllers view within that variables
> > location.
> >
> > On Oct 1, 3:05 pm, hahmadi82  wrote:
> >> Correct, I want to use stuff from my cars controller in the
> >> views/layout/default.ctp.  The only possible solution I can think is to
> >> use
> >> ajax to load some of the car stuff.  Basically, I'm curious how you can
> >> access your database from the layout file.
> >>
> >>
> >>
> >> Miles J wrote:
> >>
> >> > Im sorry but I dont understand what you are asking.
> >>
> >> > Layout toolbar? Controller class? Do you mean component?
> >>
> >> > Layout has no controller? Not sure what you mean there.
> >>
> >> > Database in layout? You mean your result right?
> >>
> >> > On Oct 1, 1:52 pm, hahmadi82  wrote:
> >> >> Hi,
> >>
> >> >> I built a class with controller/views that I want displayed in my
> >> layout
> >> >> toolbar.  Is this possible?  How can I use this queried data in my
> >> layout
> >> >> file?  Since layout has no controller, I'm not sure how I can use any
> >> >> database stuff in the layout
> >> >> --
> >> >> View this message in
> >> >>
> >> context:
> http://www.nabble.com/Access-Classes-In-Layout-Help---tp25706283p2570...
> >> >> Sent from the CakePHP mailing list archive at Nabble.com.
> >>
> >> --
> >> View this message in
> >> context:
> http://www.nabble.com/Access-Classes-In-Layout-Help---tp25706283p2570...
> >> Sent from the CakePHP mailing list archive at Nabble.com.
> > >
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Access-Classes-In-Layout-Help---tp25706283p25711954.html
> Sent from the CakePHP mailing list archive at Nabble.com.
>
>
> >
>

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Access Classes In Layout Help??

2009-10-02 Thread hahmadi82


I'm not sure I follow.  How do I pass the information into the layout file?

Miles J wrote:
> 
> 
> Just put  in your layout file, and
> then Cake will render your controllers view within that variables
> location.
> 
> On Oct 1, 3:05 pm, hahmadi82  wrote:
>> Correct, I want to use stuff from my cars controller in the
>> views/layout/default.ctp.  The only possible solution I can think is to
>> use
>> ajax to load some of the car stuff.  Basically, I'm curious how you can
>> access your database from the layout file.
>>
>>
>>
>> Miles J wrote:
>>
>> > Im sorry but I dont understand what you are asking.
>>
>> > Layout toolbar? Controller class? Do you mean component?
>>
>> > Layout has no controller? Not sure what you mean there.
>>
>> > Database in layout? You mean your result right?
>>
>> > On Oct 1, 1:52 pm, hahmadi82  wrote:
>> >> Hi,
>>
>> >> I built a class with controller/views that I want displayed in my
>> layout
>> >> toolbar.  Is this possible?  How can I use this queried data in my
>> layout
>> >> file?  Since layout has no controller, I'm not sure how I can use any
>> >> database stuff in the layout
>> >> --
>> >> View this message in
>> >>
>> context:http://www.nabble.com/Access-Classes-In-Layout-Help---tp25706283p2570...
>> >> Sent from the CakePHP mailing list archive at Nabble.com.
>>
>> --
>> View this message in
>> context:http://www.nabble.com/Access-Classes-In-Layout-Help---tp25706283p2570...
>> Sent from the CakePHP mailing list archive at Nabble.com.
> > 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Access-Classes-In-Layout-Help---tp25706283p25711954.html
Sent from the CakePHP mailing list archive at Nabble.com.


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Access Classes In Layout Help??

2009-10-01 Thread Bert Van den Brande
Well, you should test it out, but from what I can see in the source code the
controller's view is rendered first and then passed on to the layout
$content_for_layout.

During this process it merges $this->viewVars , so I would presume that
every information you made available for the controller's view will also be
available for the layout.

If this works, then I would suggest to add your layout data to the view
inside the beforeFilter() method of AppController and then use this data in
your layout. Might even consider creating an element for the part that uses
this data ...


Friendly greetings,
Bert

On Fri, Oct 2, 2009 at 12:14 AM, Miles J  wrote:

>
> Just put  in your layout file, and
> then Cake will render your controllers view within that variables
> location.
>
> On Oct 1, 3:05 pm, hahmadi82  wrote:
> > Correct, I want to use stuff from my cars controller in the
> > views/layout/default.ctp.  The only possible solution I can think is to
> use
> > ajax to load some of the car stuff.  Basically, I'm curious how you can
> > access your database from the layout file.
> >
> >
> >
> > Miles J wrote:
> >
> > > Im sorry but I dont understand what you are asking.
> >
> > > Layout toolbar? Controller class? Do you mean component?
> >
> > > Layout has no controller? Not sure what you mean there.
> >
> > > Database in layout? You mean your result right?
> >
> > > On Oct 1, 1:52 pm, hahmadi82  wrote:
> > >> Hi,
> >
> > >> I built a class with controller/views that I want displayed in my
> layout
> > >> toolbar.  Is this possible?  How can I use this queried data in my
> layout
> > >> file?  Since layout has no controller, I'm not sure how I can use any
> > >> database stuff in the layout
> > >> --
> > >> View this message in
> > >> context:
> http://www.nabble.com/Access-Classes-In-Layout-Help---tp25706283p2570...
> > >> Sent from the CakePHP mailing list archive at Nabble.com.
> >
> > --
> > View this message in context:
> http://www.nabble.com/Access-Classes-In-Layout-Help---tp25706283p2570...
> > Sent from the CakePHP mailing list archive at Nabble.com.
> >
>

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Access Classes In Layout Help??

2009-10-01 Thread Miles J

Just put  in your layout file, and
then Cake will render your controllers view within that variables
location.

On Oct 1, 3:05 pm, hahmadi82  wrote:
> Correct, I want to use stuff from my cars controller in the
> views/layout/default.ctp.  The only possible solution I can think is to use
> ajax to load some of the car stuff.  Basically, I'm curious how you can
> access your database from the layout file.
>
>
>
> Miles J wrote:
>
> > Im sorry but I dont understand what you are asking.
>
> > Layout toolbar? Controller class? Do you mean component?
>
> > Layout has no controller? Not sure what you mean there.
>
> > Database in layout? You mean your result right?
>
> > On Oct 1, 1:52 pm, hahmadi82  wrote:
> >> Hi,
>
> >> I built a class with controller/views that I want displayed in my layout
> >> toolbar.  Is this possible?  How can I use this queried data in my layout
> >> file?  Since layout has no controller, I'm not sure how I can use any
> >> database stuff in the layout
> >> --
> >> View this message in
> >> context:http://www.nabble.com/Access-Classes-In-Layout-Help---tp25706283p2570...
> >> Sent from the CakePHP mailing list archive at Nabble.com.
>
> --
> View this message in 
> context:http://www.nabble.com/Access-Classes-In-Layout-Help---tp25706283p2570...
> Sent from the CakePHP mailing list archive at Nabble.com.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Access Classes In Layout Help??

2009-10-01 Thread hahmadi82


Correct, I want to use stuff from my cars controller in the
views/layout/default.ctp.  The only possible solution I can think is to use
ajax to load some of the car stuff.  Basically, I'm curious how you can
access your database from the layout file.



Miles J wrote:
> 
> 
> Im sorry but I dont understand what you are asking.
> 
> Layout toolbar? Controller class? Do you mean component?
> 
> Layout has no controller? Not sure what you mean there.
> 
> Database in layout? You mean your result right?
> 
> On Oct 1, 1:52 pm, hahmadi82  wrote:
>> Hi,
>>
>> I built a class with controller/views that I want displayed in my layout
>> toolbar.  Is this possible?  How can I use this queried data in my layout
>> file?  Since layout has no controller, I'm not sure how I can use any
>> database stuff in the layout
>> --
>> View this message in
>> context:http://www.nabble.com/Access-Classes-In-Layout-Help---tp25706283p2570...
>> Sent from the CakePHP mailing list archive at Nabble.com.
> > 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Access-Classes-In-Layout-Help---tp25706283p25707318.html
Sent from the CakePHP mailing list archive at Nabble.com.


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Access Classes In Layout Help??

2009-10-01 Thread Bert Van den Brande
I think he means that he has written a controller+view that generates some
output.

Now he wants to render the same output inside his layout file ...

Correct hahmadi ?

On Thu, Oct 1, 2009 at 11:41 PM, Miles J  wrote:

>
> Im sorry but I dont understand what you are asking.
>
> Layout toolbar? Controller class? Do you mean component?
>
> Layout has no controller? Not sure what you mean there.
>
> Database in layout? You mean your result right?
>
> On Oct 1, 1:52 pm, hahmadi82  wrote:
> > Hi,
> >
> > I built a class with controller/views that I want displayed in my layout
> > toolbar.  Is this possible?  How can I use this queried data in my layout
> > file?  Since layout has no controller, I'm not sure how I can use any
> > database stuff in the layout
> > --
> > View this message in context:
> http://www.nabble.com/Access-Classes-In-Layout-Help---tp25706283p2570...
> > Sent from the CakePHP mailing list archive at Nabble.com.
> >
>

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Access Classes In Layout Help??

2009-10-01 Thread Miles J

Im sorry but I dont understand what you are asking.

Layout toolbar? Controller class? Do you mean component?

Layout has no controller? Not sure what you mean there.

Database in layout? You mean your result right?

On Oct 1, 1:52 pm, hahmadi82  wrote:
> Hi,
>
> I built a class with controller/views that I want displayed in my layout
> toolbar.  Is this possible?  How can I use this queried data in my layout
> file?  Since layout has no controller, I'm not sure how I can use any
> database stuff in the layout
> --
> View this message in 
> context:http://www.nabble.com/Access-Classes-In-Layout-Help---tp25706283p2570...
> Sent from the CakePHP mailing list archive at Nabble.com.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Access Classes In Layout Help??

2009-10-01 Thread hahmadi82


Hi,

I built a class with controller/views that I want displayed in my layout
toolbar.  Is this possible?  How can I use this queried data in my layout
file?  Since layout has no controller, I'm not sure how I can use any
database stuff in the layout
-- 
View this message in context: 
http://www.nabble.com/Access-Classes-In-Layout-Help---tp25706283p25706283.html
Sent from the CakePHP mailing list archive at Nabble.com.


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Tabs in Layout... Help Please.

2009-01-16 Thread Martin Westin

@Andrew
The reason the "li.active" method is so widely used is that is works
for CMSes and other "dynamic" applications where the contents of the
menu changes. The technique you describe uses hard-coded menu items
which I very rarely find to be sufficient for the applications I work
on.




On Jan 15, 10:05 pm, "ache...@gmail.com"  wrote:
> Nurvzy,
>
> Yes! This is the first time I've written anything and then been able
> to link to it. I don't like the idea of using your server to process
> this, I think it's a task much better suited to CSS I wrote about it
> here if you want to take a lookhttp://www.lifeiscake.com/posts/view/css-menus
>
> Sincerely,
> ~Andrew Allen
>
> On Jan 13, 4:05 pm, nurvzy  wrote:
>
> > Hi All,
>
> >   I'm new to cakephp and working through my first cake app.  I'm
> > chugging along and am now stumped as to where to put a function I've
> > written to help decide if a navigation tab should have the
> > id="selected" assigned to the anchor tag.
>
> > Basically the gist is I have a  Navigation bar with various links:
> > (Home, Contact, ect..) and depending on the current controller or
> > action or whatever I pass in; I want the id of that  tag to be
> > "selected".
>
> > So I've written a little function:
>
> > function is_selected($controller_or_action, $link_text){
> >   if (strpos($controller_or_action,$link_text) !== false) return true;
> >   else return false;
>
> > }
>
> > And I'm calling it like so in the default.ctp layout:
>
> >  >  if(is_selected($this->params['controller'], "pages")) echo $html->link
> > ('Contact', array('controller' => 'pages', 'action' => 'contactus'),
> > array('id' => 'selected'));
> > else echo $html->link('Contact', array('controller' => 'pages',
> > 'action' => 'contactus'));
> >  ?>
>
> > But that's really tedious and quite ugly, plus I have that function
> > just written at the top of the layout which is a big no-no.  So I'm
> > looking for some help/advice.  How do you specify a tab type layout in
> > your cake app?
>
> > Thank you for your advice and/or help.
> > Nick
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Tabs in Layout... Help Please.

2009-01-15 Thread nurvzy

@Andrew: Thank you very much for the link to your great article; its
well written and much appreciated.

Thank you all for your quick responses, help and advice.  Very much
appreciated!

Nick
On Jan 15, 2:05 pm, "ache...@gmail.com"  wrote:
> Nurvzy,
>
> Yes! This is the first time I've written anything and then been able
> to link to it. I don't like the idea of using your server to process
> this, I think it's a task much better suited to CSS I wrote about it
> here if you want to take a lookhttp://www.lifeiscake.com/posts/view/css-menus
>
> Sincerely,
> ~Andrew Allen
>
> On Jan 13, 4:05 pm, nurvzy  wrote:
>
> > Hi All,
>
> >   I'm new to cakephp and working through my first cake app.  I'm
> > chugging along and am now stumped as to where to put a function I've
> > written to help decide if a navigation tab should have the
> > id="selected" assigned to the anchor tag.
>
> > Basically the gist is I have a  Navigation bar with various links:
> > (Home, Contact, ect..) and depending on the current controller or
> > action or whatever I pass in; I want the id of that  tag to be
> > "selected".
>
> > So I've written a little function:
>
> > function is_selected($controller_or_action, $link_text){
> >   if (strpos($controller_or_action,$link_text) !== false) return true;
> >   else return false;
>
> > }
>
> > And I'm calling it like so in the default.ctp layout:
>
> >  >  if(is_selected($this->params['controller'], "pages")) echo $html->link
> > ('Contact', array('controller' => 'pages', 'action' => 'contactus'),
> > array('id' => 'selected'));
> > else echo $html->link('Contact', array('controller' => 'pages',
> > 'action' => 'contactus'));
> >  ?>
>
> > But that's really tedious and quite ugly, plus I have that function
> > just written at the top of the layout which is a big no-no.  So I'm
> > looking for some help/advice.  How do you specify a tab type layout in
> > your cake app?
>
> > Thank you for your advice and/or help.
> > Nick
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Tabs in Layout... Help Please.

2009-01-15 Thread ache...@gmail.com

Nurvzy,

Yes! This is the first time I've written anything and then been able
to link to it. I don't like the idea of using your server to process
this, I think it's a task much better suited to CSS I wrote about it
here if you want to take a look http://www.lifeiscake.com/posts/view/css-menus

Sincerely,
~Andrew Allen

On Jan 13, 4:05 pm, nurvzy  wrote:
> Hi All,
>
>   I'm new to cakephp and working through my first cake app.  I'm
> chugging along and am now stumped as to where to put a function I've
> written to help decide if a navigation tab should have the
> id="selected" assigned to the anchor tag.
>
> Basically the gist is I have a  Navigation bar with various links:
> (Home, Contact, ect..) and depending on the current controller or
> action or whatever I pass in; I want the id of that  tag to be
> "selected".
>
> So I've written a little function:
>
> function is_selected($controller_or_action, $link_text){
>   if (strpos($controller_or_action,$link_text) !== false) return true;
>   else return false;
>
> }
>
> And I'm calling it like so in the default.ctp layout:
>
>   if(is_selected($this->params['controller'], "pages")) echo $html->link
> ('Contact', array('controller' => 'pages', 'action' => 'contactus'),
> array('id' => 'selected'));
> else echo $html->link('Contact', array('controller' => 'pages',
> 'action' => 'contactus'));
>  ?>
>
> But that's really tedious and quite ugly, plus I have that function
> just written at the top of the layout which is a big no-no.  So I'm
> looking for some help/advice.  How do you specify a tab type layout in
> your cake app?
>
> Thank you for your advice and/or help.
> Nick
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Tabs in Layout... Help Please.

2009-01-14 Thread Kappa

Why not using "for_layout" variables?

Just set into your controller action a "selectedtab_for_layout"
variable and inside the
layout (yes i said layout, not view) you can access it.


On Jan 14, 5:42 pm, teknoid  wrote:
> If I understand this right, you are looking to set an "active" tab,
> based on the view you are currently in...
>
> It can be done easily from the view itself, i.e. in view_one.ctp:
> $this->set('tabOne', true); (which is now going to be available in
> your layout).
> Therefore, in the layout you could do:  'class="selected-tab"' : null; ?>
>
> On Jan 13, 6:05 pm, nurvzy  wrote:
>
> > Hi All,
>
> >   I'm new to cakephp and working through my first cake app.  I'm
> > chugging along and am now stumped as to where to put a function I've
> > written to help decide if a navigation tab should have the
> > id="selected" assigned to the anchor tag.
>
> > Basically the gist is I have a  Navigation bar with various links:
> > (Home, Contact, ect..) and depending on the current controller or
> > action or whatever I pass in; I want the id of that  tag to be
> > "selected".
>
> > So I've written a little function:
>
> > function is_selected($controller_or_action, $link_text){
> >   if (strpos($controller_or_action,$link_text) !== false) return true;
> >   else return false;
>
> > }
>
> > And I'm calling it like so in the default.ctp layout:
>
> >  >  if(is_selected($this->params['controller'], "pages")) echo $html->link
> > ('Contact', array('controller' => 'pages', 'action' => 'contactus'),
> > array('id' => 'selected'));
> > else echo $html->link('Contact', array('controller' => 'pages',
> > 'action' => 'contactus'));
> >  ?>
>
> > But that's really tedious and quite ugly, plus I have that function
> > just written at the top of the layout which is a big no-no.  So I'm
> > looking for some help/advice.  How do you specify a tab type layout in
> > your cake app?
>
> > Thank you for your advice and/or help.
> > Nick
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Tabs in Layout... Help Please.

2009-01-14 Thread teknoid

If I understand this right, you are looking to set an "active" tab,
based on the view you are currently in...

It can be done easily from the view itself, i.e. in view_one.ctp:
$this->set('tabOne', true); (which is now going to be available in
your layout).
Therefore, in the layout you could do: 

On Jan 13, 6:05 pm, nurvzy  wrote:
> Hi All,
>
>   I'm new to cakephp and working through my first cake app.  I'm
> chugging along and am now stumped as to where to put a function I've
> written to help decide if a navigation tab should have the
> id="selected" assigned to the anchor tag.
>
> Basically the gist is I have a  Navigation bar with various links:
> (Home, Contact, ect..) and depending on the current controller or
> action or whatever I pass in; I want the id of that  tag to be
> "selected".
>
> So I've written a little function:
>
> function is_selected($controller_or_action, $link_text){
>   if (strpos($controller_or_action,$link_text) !== false) return true;
>   else return false;
>
> }
>
> And I'm calling it like so in the default.ctp layout:
>
>   if(is_selected($this->params['controller'], "pages")) echo $html->link
> ('Contact', array('controller' => 'pages', 'action' => 'contactus'),
> array('id' => 'selected'));
> else echo $html->link('Contact', array('controller' => 'pages',
> 'action' => 'contactus'));
>  ?>
>
> But that's really tedious and quite ugly, plus I have that function
> just written at the top of the layout which is a big no-no.  So I'm
> looking for some help/advice.  How do you specify a tab type layout in
> your cake app?
>
> Thank you for your advice and/or help.
> Nick
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Tabs in Layout... Help Please.

2009-01-14 Thread nurvzy

A That's mighty clever too Martin, thanks for sharing.  I have a
static menu but I like the idea of not having to pass anything to the
view and the layout figuring out where it is on its own.  My problem
is I'm using the same pages controller to display 3 of my 6 tabs with
static content, so the controller name is the same 3 out of 6 times so
I needed another way to decide between them all.

But thanks for sharing, I'll keep that in mind for my next projects.

On Jan 14, 3:36 am, Martin Westin  wrote:
> One technique I have used where I want it to be as automatic as
> possible (but possibly not compatible with any routing scenario) is
> this:
>
> My main menu consists of either plugins or controllers (some of each
> kind.) So I use this to figure out what the current plugin or top-
> level controller is:
> ---
> if ( empty($this->plugin) ) {
>     $module_name = $this->name;} else {
>
>     $module_name = $this->plugin;}
>
> ---
> Then I loop the currently available "modules" (controllers and plugins
> that should be visible).
> For each one I compare its name to the one extracted above and set the
> class to selected if it matches.
> ---
> foreach($modules as $one) {
>     $class = '';
>     if ( low($module_name) == low($one) ) {
>         $class = ' selected';
>     }
>     e('');
>     e( $html->link(___('main_menu_'.$one),'/'.$one) );
>     e('');}
>
> ---
> For the links I only need to go to the index action but there is
> nothing stopping you from using more detailed menu-data to make more
> complex versions of this technique.
>
> What I like it that I don't need any specific (hard coded) information
> in my layout. I can change out the available menuitems at any time. I
> do this to adapt the menu to the permissions each user has. They only
> need to see items that they actually can access. I construct the list
> of available "modules" in AppController::beforeFilter after Auth has
> done its thing.
>
> /Martin
>
> On Jan 14, 3:05 am, nurvzy  wrote:
>
> > Thank you Miles!
>
> > That technique is exactly what I was looking for!
>
> > Nick
>
> > On Jan 13, 5:04 pm, Miles J  wrote:
>
> > > This is how I do mine:
>
> > > // controller action
> > > function login() {
> > >         $this->set('activeTab', 'login');
>
> > > }
>
> > > // the view
> > > > > > href="#">Login
> > > > > > href="#">Signup
>
> > > Also, your function would go in the bootstrap.php file in your app/
> > > config/ folder.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Tabs in Layout... Help Please.

2009-01-14 Thread Martin Westin


One technique I have used where I want it to be as automatic as
possible (but possibly not compatible with any routing scenario) is
this:

My main menu consists of either plugins or controllers (some of each
kind.) So I use this to figure out what the current plugin or top-
level controller is:
---
if ( empty($this->plugin) ) {
$module_name = $this->name;
} else {
$module_name = $this->plugin;
}
---
Then I loop the currently available "modules" (controllers and plugins
that should be visible).
For each one I compare its name to the one extracted above and set the
class to selected if it matches.
---
foreach($modules as $one) {
$class = '';
if ( low($module_name) == low($one) ) {
$class = ' selected';
}
e('');
e( $html->link(___('main_menu_'.$one),'/'.$one) );
e('');
}
---
For the links I only need to go to the index action but there is
nothing stopping you from using more detailed menu-data to make more
complex versions of this technique.

What I like it that I don't need any specific (hard coded) information
in my layout. I can change out the available menuitems at any time. I
do this to adapt the menu to the permissions each user has. They only
need to see items that they actually can access. I construct the list
of available "modules" in AppController::beforeFilter after Auth has
done its thing.

/Martin


On Jan 14, 3:05 am, nurvzy  wrote:
> Thank you Miles!
>
> That technique is exactly what I was looking for!
>
> Nick
>
> On Jan 13, 5:04 pm, Miles J  wrote:
>
> > This is how I do mine:
>
> > // controller action
> > function login() {
> >         $this->set('activeTab', 'login');
>
> > }
>
> > // the view
> > > > href="#">Login
> > > > href="#">Signup
>
> > Also, your function would go in the bootstrap.php file in your app/
> > config/ folder.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Tabs in Layout... Help Please.

2009-01-13 Thread nurvzy

Thank you Miles!

That technique is exactly what I was looking for!

Nick

On Jan 13, 5:04 pm, Miles J  wrote:
> This is how I do mine:
>
> // controller action
> function login() {
>         $this->set('activeTab', 'login');
>
> }
>
> // the view
> > href="#">Login
> > href="#">Signup
>
> Also, your function would go in the bootstrap.php file in your app/
> config/ folder.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Tabs in Layout... Help Please.

2009-01-13 Thread Miles J

This is how I do mine:

// controller action
function login() {
$this->set('activeTab', 'login');
}

// the view
>Login
>Signup

Also, your function would go in the bootstrap.php file in your app/
config/ folder.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Tabs in Layout... Help Please.

2009-01-13 Thread nurvzy

Hi All,

  I'm new to cakephp and working through my first cake app.  I'm
chugging along and am now stumped as to where to put a function I've
written to help decide if a navigation tab should have the
id="selected" assigned to the anchor tag.

Basically the gist is I have a  Navigation bar with various links:
(Home, Contact, ect..) and depending on the current controller or
action or whatever I pass in; I want the id of that  tag to be
"selected".

So I've written a little function:

function is_selected($controller_or_action, $link_text){
  if (strpos($controller_or_action,$link_text) !== false) return true;
  else return false;
}

And I'm calling it like so in the default.ctp layout:

params['controller'], "pages")) echo $html->link
('Contact', array('controller' => 'pages', 'action' => 'contactus'),
array('id' => 'selected'));
else echo $html->link('Contact', array('controller' => 'pages',
'action' => 'contactus'));
 ?>

But that's really tedious and quite ugly, plus I have that function
just written at the top of the layout which is a big no-no.  So I'm
looking for some help/advice.  How do you specify a tab type layout in
your cake app?

Thank you for your advice and/or help.
Nick
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Layout Help

2006-06-09 Thread Garth Braithwaite

Not exactly what I was asking, but chapter 6 is great, and I think I
figured it out.  Thanks for you help.


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Layout Help

2006-06-08 Thread John Zimmerman [gmail]
The chapter on Models should get you started here.http://manual.cakephp.org/chapter/6Basically you need to query your model using $this->Post->find($yourparamshere) which will return an array of results.
If you do a pr($result) it will output the structure of your array in the browser and you can see how to access the title.  At that point you can do what you like with it.On 6/8/06, 
Garth Braithwaite <[EMAIL PROTECTED]> wrote:
IT makes perfect senses.  Question number two is solved.  On questionone I figured that was the answer, but I guess my real question is howdo I retrieve the title of the blog post from the database in thecontroller before I use $this->pageTitle = $PostTitle;?   I know how to
do this using php, but I am guessing there is a cleaner way to do inthe cake php.

--~--~-~--~~~---~--~~
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  -~--~~~~--~~--~--~---


Re: Layout Help

2006-06-08 Thread Garth Braithwaite

IT makes perfect senses.  Question number two is solved.  On question
one I figured that was the answer, but I guess my real question is how
do I retrieve the title of the blog post from the database in the
controller before I use $this->pageTitle = $PostTitle;?   I know how to
do this using php, but I am guessing there is a cleaner way to do in
the cake php.


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Layout Help

2006-06-07 Thread John Zimmerman [gmail]
Question 1:In each of your action functions you can change the value of $pageTitle before the pages is rendered.  So if you want to change the title to the Post title your would do $this->pageTitle = $PostTitle; before the end of your action function.  You can conditionally set the title and if it is not changed it will display whatever you set it to in the class variable.
In my controllers I set pagetTitle to null if I don't want to be displayed and in my layout I check to make sure it is not set to null before displaying.  That way on pages I do not want a title it won't be there.
Question 2:You can do something similar to my solution for pageTitle in question 1.  You set a default value for the css file name and make it a variable (i.e. $css_file) and subsititute that variable when including your css value.
In your controller you would call $this->set('css_file', 'new_file_name');In your view you would check to make sure $css_file is already set, if it is not you set it in your layout equal to your default css file.
If that doesn't make sense I am sure we can come up with some specific code snippets.On 6/7/06, Garth Braithwaite <
[EMAIL PROTECTED]> wrote:I followed along with the blog tutorial in the manual and now a I am
customizing it to my needs.  I figured out I could change the pagetitle by assigning it to the variable $this->pageTitle = 'Blog'; likeso and I then can echo it out in the custom layout.  This works great
in most of the functions in the controller, however I want to make itso that when you view the individual post it passes through the titleof the post stored in the database as $this->pageTitle  .That is my first question, my second: Is there anyway to make any other
variables that I can pass through for layout sake other than$content_for_layout and $title_for_layout, for example I want to usethe same layout but use a different css (I do not want to create a newlayout for the new css, but just change the text in the css link tag).
Any help is appreciated.
--~--~-~--~~~---~--~~
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  -~--~~~~--~~--~--~---


Layout Help

2006-06-07 Thread Garth Braithwaite

I followed along with the blog tutorial in the manual and now a I am
customizing it to my needs.  I figured out I could change the page
title by assigning it to the variable $this->pageTitle = 'Blog'; like
so and I then can echo it out in the custom layout.  This works great
in most of the functions in the controller, however I want to make it
so that when you view the individual post it passes through the title
of the post stored in the database as $this->pageTitle  .

That is my first question, my second: Is there anyway to make any other
variables that I can pass through for layout sake other than
$content_for_layout and $title_for_layout, for example I want to use
the same layout but use a different css (I do not want to create a new
layout for the new css, but just change the text in the css link tag).

Any help is appreciated.


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: CakePHP layout help please

2006-05-08 Thread Dinh
You can see it here: http://wiki.cakephp.org/tutorials_routes#admin_routesOn 5/9/06, tehsuck
 <[EMAIL PROTECTED]> wrote:I am a newbie, so I really didn't know about admin routes. 


--~--~-~--~~~---~--~~
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  -~--~~~~--~~--~--~---


Re: CakePHP layout help please

2006-05-08 Thread tehsuck

I am a newbie, so I really didn't know about admin routes. However, I
don't think it would really suit my needs. The frontend of this site is
non-cake based, it's flash, so the root web directory should be free of
anything dealing with administration / cake. I am just remoting for a
flash movie. In other words: the only person using this app would be
the site owner/admin to manage content.


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: CakePHP layout help please

2006-05-08 Thread Larry E. Masters aka PhpNut
Why are you not using cake admin routes?Do you plan to have a non admin side to this app also, that will use the same controller names?-- /*** @author Larry E. Masters* @var string $userName
* @param string $realName* @returns string aka PhpNut* @access  public*/ 


--~--~-~--~~~---~--~~
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  -~--~~~~--~~--~--~---


Re: CakePHP layout help please

2006-05-08 Thread tehsuck

Ok, helping myself out here, but just in case anyone else is looking
for the same info.

I don't know if you can set CakePHP up like how I wanted to, so I went
back to how the "alternate" config is setup in the manual and I did it
that way.

So in my case, I wanted http://www.jim.com/admin/ to be the root of my
app.

So what I had to do was copy my /app directory to /home/jim/admin
Then I moved /home/jim/admin/webroot/ to the proper location:
/home/jim/public_html/admin/

I changed my ROOT to define('ROOT', DS.'home'.DS.'jim');

and my APP_DIR to define('APP_DIR', 'admin');

And things seem to be working as they should be, now
http://www.jim.com/admin/controller_name/ works!

..and knowing is half the battle. Yay. If anyone needs a hand, feel
free to e-mail me.


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: CakePHP layout help please

2006-05-08 Thread tehsuck

Hmm, well I changed my index.php to use .DS. syntax and it's still not
working. Ok, but get this: http://www.jim.com/admin/controller_name/
doesn't work, but http://www.jim.com/admin/app/controller_name/ does.
So is this something with mod_rewrite?


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: CakePHP layout help please

2006-05-08 Thread calzone

I'm no expert on this, but having just tried something similar, I
discovered what may appears to be a bug with one of the core cake
files:

Check out:
http://groups.google.com/group/cake-php/browse_thread/thread/a6e45271704f6798

Close to the bottom of the thread is an explanation.


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



CakePHP layout help please

2006-05-08 Thread tehsuck

I am just getting into Cake, and I really like it so far. It is going
to speed up some of the work I do. Here is my problem though.

I run a VPS, and since I have clients hosting with us, it's probably a
good idea to keep the cake/cake files in a central place, so I put them
in /usr/local/lib/php/cake/.

I have a client, we'll say his name is Jim. I am going to be running an
admin tool for him, so I want http://www.jim.com/admin/ to be the site
root for the cake app.

Jim's web files live at /home/jim/public_html/
So Jim's admin is at /home/jim/public_html/admin/
Jim's cake app is at /home/jim/public_html/admin/app/
Jim's 'webroot' folder is at /home/jim/public_html/admin/app/webroot/

Does that make sense?

Anyhow, I can get cake to say everything is ok, but mod_rewrite doesn't
seem to be working. My base site http://www.jim.com/admin/ comes up
with proper content, but all the CSS and images are missing. I have
changed my routes.php to see if my controller was working (and it is),
but if I go to http://www.jim.com/admin/controller_name/ I get a 404
error, as if the server is not re-writing the URL at all.


I have modified my /home/public_html/admin/app/webroot/index.php as
follows:

if (!defined('ROOT'))
{
//define('ROOT', 'FULL PATH TO DIRECTORY WHERE APP DIRECTORY IS LOCATED
DO NOT ADD A TRAILING DIRECTORY SEPARATOR';
//You should also use the DS define to seperate your directories
define('ROOT', DS.'home'.DS.'jim'.DS.'public_html'.DS.'admin');
}

if (!defined('APP_DIR'))
{
//define('APP_DIR', 'DIRECTORY NAME OF APPLICATION';
define ('APP_DIR', basename(dirname(dirname(__FILE__;
}

/**
 * This only needs to be changed if the cake installed libs are located
 * outside of the distributed directory structure.
 */
if (!defined('CAKE_CORE_INCLUDE_PATH'))
{
//define ('CAKE_CORE_INCLUDE_PATH', FULL PATH TO DIRECTORY WHERE CAKE
CORE IS INSTALLED DO NOT ADD A TRAILING DIRECTORY$
//You should also use the DS define to seperate your directories
define('CAKE_CORE_INCLUDE_PATH', '/usr/local/lib/php/cake');
}

I followed the documentation in the manual, but I can't figure out
what's going on.

Thanks for any help!


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---