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 <hahmad...@gmail.com> 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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---
No comments:
Post a Comment