On Fri, Aug 3, 2012 at 9:22 AM, kevin.ncbible <kevin@ncbible.com> wrote:
>
> 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.
Yes, that's right. In any class, $this refers to the instantiated object.
> 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.
Yes, that's a very good way of putting it. The set() method makes
variables available to the View object. More specifically, it add the
var to the controller's $viewVars array, which Cake makes available to
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!
Tentatively, yes. I couldn't say for sure without knowing more about
what you're doing.
--
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
Friday, August 3, 2012
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment