Cakephp how should you manage controllers and views -


I'm totally new to KHHP, so I'm completely confused that the various controls / views / elements How Management Works / P>

PROBLEM: I am trying to create my home page, which has a page controller and see home.ctp. Now, I have another controller, Idea controller, which includes functions to load all the ideas from DB.

  Public function index () {$ this-> Set ('title_for_layout', 'ideas'); $ This- & gt; Set ('idea', $ this-> idea-> search ('all')); }  

Now, I need to access this Idea Controller with multiple (up to 3) different views. What is the best way to do this?

Thanks -

You are going to the other side ...

The view controller does not have "access", the controller receives a request, tells the model what information they need, and passes all necessary data views. Thoughts are like small dolls that can put clothes on you, but nothing more than that, they do not play or play or ask random questions to you.

Generally speaking, there is only one view per action in a controller. If you need to "access" the controller with different ideas, then you may be a little confused with the cake.

Without knowing the exact reason for doing this, I would like to assume that if you have the "Access" controller to get all the ideas from BD with 3 different views, then this is the case. The standard way is:

1) Create a function in the appropriate model:

  // Idea model public function getAll () {return this $ -> The idea is & gt; It seems ('all'); }  

OK, you really need to do this to do this, because it is very easy, but for more complex cases where you get only ideas

2) Look for every action in the controller that will be required

Em> that data, you

  Public Function randomAction () {$ this-> Set ('idea', $ this-> idea- & gt; getAll ()); }  

3) You get data in each view

  pr ($ ideas);  

And this is that

The idea never "access" the controller, so your question becomes a bit confusing. Maybe you mean 3 ideas related to the same action, but there is also little reason to do this ... or else for "visual" in "other" scenes, like "data", stack overflow But, which repeats everywhere, you have to keep it in a lot of thoughts, if this was the case, then you have to do that to re-use that element in the other aspects of "view".

If you want a little bit more, then maybe I can answer a lot, it is better, but I hope at least I have given you the instruction that where you want to see or What do you want to do


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -