Tuesday, June 19, 2012

Re: Caching part of view and user-specific sidebar problem

Yes, you can use requestAction from within an element.

in your element you can write
$data = $this->requestAction(array('controller' => 'test', 'action' =>
'getdataforelementaction' ));

and in your controller

public function getdataforelementaction() {
if (isset($this->params['requested'])) {
return $this->Modelname->find_your_data();
}
}

more at: http://book.cakephp.org/1.3/en/view/991/requestAction or
http://book.cakephp.org/2.0/en/controllers.html#Controller::requestAction

On Jun 19, 12:25 am, Joris Vaesen <vaesen.jo...@gmail.com> wrote:
> I've build an application with a where where users can see multiple items.
> These items are sorted by pagination.
>
> Because of the big amount of items per page would i like to do some caching.
> Because the page is using pagination, I can't cache the query.
>
> So I was thinking about caching the view, which works very well but one
> thing:
> The sidebar on the page is user-specific and may not be cached.
> So I separated this part in an element and used the <!--nocache--> html
> comment technique.
>
> Now is my problem that i can't get any data in this element. The data for
> this element may not be cached.
> The only oppertunity thought of was doing some queries in de element to get
> recent data.
>
> But is this in any way possible to query from an element?

--
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