Dynamic Elements

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Dynamic Elements

GL-4

Hi All!

Can anyone help me with following question?

Let's (for example) I have blog application. And I have some posts
categories. I'd like to have an element, that shows on every page my
categories list.

How can I do this?

Elements don't have access to controllers. I don't want to include
Categories model in every controller that I have in application. I want
to do it from template...

Is it possible?

Best Regards


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake PHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Dynamic Elements

fr33dom

requestAction maybe?

if i understand correctly, you would like to display you list of
categories on every page yes?

within your element you could call:

$this->requestAction('categories/list');

There was some discussion a while back as to the overhead of too many
of these calls. Was an interesting one, looked at using this method
against including models in other controllers where necessary. both
have uses.

do a quick search on requestaction and there are some interesting posts.

HTH
mikee

On 31/10/06, GL <[hidden email]> wrote:

>
> Hi All!
>
> Can anyone help me with following question?
>
> Let's (for example) I have blog application. And I have some posts
> categories. I'd like to have an element, that shows on every page my
> categories list.
>
> How can I do this?
>
> Elements don't have access to controllers. I don't want to include
> Categories model in every controller that I have in application. I want
> to do it from template...
>
> Is it possible?
>
> Best Regards
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake PHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Dynamic Elements

GL-4

As far as I understand I can't use requestAction inside element.

I solved it by calling

<?= $this->renderElement('catmenu',
array('categories'=>$this->requestAction('/categories/getlist'))); ?>

from my layout template.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake PHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Dynamic Elements

cadraig

You might want to think about 'baking' your element instead, if it
doesn't change too regularly:

http://wiki.cakephp.org/tutorials:dynamic-menu

This ought to take the load off your db server.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake PHP" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---