Friday, August 3, 2012

Re: Proper MVC location for a function and its call

cricket:

Ahhhh. That was it. So, it makes sense doesn't it, that when you're in the model you do not need to reference the model, so  $this->getPath(...)  is enough. So, in MVC terminology, I'm using the model to retrieve the data.

re: Set, although I had read about it, I also was not getting the significance of set to the MVC pattern. I assume that is the main reason, for instance, that I would not be calling a function FROM the view: it's more like the Model and Controller are pushing (I'm sure there's a better word) the data to the view. 

Now, in my case, the $id value for a particular topic is available in the view or edit action, but not in the index or add action. So you've really helped me with making the "level" variable available to the view or edit action. What if, however, for the index page, I had the $id available, but only via a request param. Would that be a case where set would not work and I would have to somehow call the getLevel function right from the view? Ahhhh. I guess I do have $id available, in the index action, via $id = $this->request->params['named']['id']; Then I could go ahead and use $this->set('level', $this->TopicTree->getLevel($id)); Does that make sense? I'll have to try that!

As you can see, I'm trying to get my head around MVC patterns, how they play out on the practical level. Thank you, cricket and others, so very much, for helping me to do this!

Kevin

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
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

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate