Access the model name from a view

2009-07-20 Thread jordicakephp

Hi again, my dear baker friends.

Until now, when I've written this in a controller:


$paginatedQuery = $this-paginate($this-modelClass);


I've coded this in a view to access the information that it returns
(inside a foreach loop, of course):


$row['ModelName']['user_login']


That is, hard-coding the name of the model in the view. My doubt is:
How can I access, from a view, the name of its associated model? I
haven't been able to find this answer!

Again, thanks a lot in advance for your time (I promise not to write
more messages today ;-)

--~--~-~--~~~---~--~~
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 the model name from a view

2009-07-20 Thread grigri

How about

$modelName = key($this-params['paging']);

That should do the trick.

hth
grigri

On Jul 20, 11:47 am, jordicakephp jordicake...@gmail.com wrote:
 Hi again, my dear baker friends.

 Until now, when I've written this in a controller:

 $paginatedQuery = $this-paginate($this-modelClass);

 I've coded this in a view to access the information that it returns
 (inside a foreach loop, of course):

 $row['ModelName']['user_login']

 That is, hard-coding the name of the model in the view. My doubt is:
 How can I access, from a view, the name of its associated model? I
 haven't been able to find this answer!

 Again, thanks a lot in advance for your time (I promise not to write
 more messages today ;-)
--~--~-~--~~~---~--~~
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 the model name from a view

2009-07-20 Thread jordicakephp

Thanks a lot, grigri.

Your trick worked perfectly and I didn't know I can access the
parameters of a view in the same way I access the parameters of a
controller.

What a disaster!

Regards.

On 20 jul, 14:19, grigri j...@hendersonwebdesign.com wrote:
 How about

 $modelName = key($this-params['paging']);

 That should do the trick.

 hth
 grigri

 On Jul 20, 11:47 am, jordicakephp jordicake...@gmail.com wrote:

  Hi again, my dear baker friends.

  Until now, when I've written this in a controller:

  $paginatedQuery = $this-paginate($this-modelClass);

  I've coded this in a view to access the information that it returns
  (inside a foreach loop, of course):

  $row['ModelName']['user_login']

  That is, hard-coding the name of the model in the view. My doubt is:
  How can I access, from a view, the name of its associated model? I
  haven't been able to find this answer!

  Again, thanks a lot in advance for your time (I promise not to write
  more messages today ;-)
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---