From faa0d1d57d8d63bf71e2a163ae6d69fe903e1ae0 Mon Sep 17 00:00:00 2001 From: David Yell Date: Thu, 10 Sep 2015 15:20:15 +0100 Subject: [PATCH 1/2] Update views.rst Remove the section about the use of requestAction, now that View Cells are the better way to do this we don't want new Cake 3 developers picking up requestAction without an idea of it's overheads. --- en/views.rst | 42 ------------------------------------------ 1 file changed, 42 deletions(-) diff --git a/en/views.rst b/en/views.rst index 45dba5f4bc..5e96a31205 100644 --- a/en/views.rst +++ b/en/views.rst @@ -550,48 +550,6 @@ application, provide a unique cache key value using the following format:: ] ); -You can take full advantage of elements by using -``requestAction()``, which fetches view -variables from a controller action and returns them as an array. -This enables your elements to perform in true MVC style. Create a -controller action that prepares the view variables for your -elements, then call ``requestAction()`` inside the second parameter -of ``element()`` to feed the element the view variables from your -controller. - -To do this, in your controller add something like the following for -the Post example:: - - namespace App\Controller; - - class PostsController extends AppController - { - // ... - public function index() - { - $posts = $this->paginate(); - if ($this->request->is('requested')) { - return $posts; - } else { - $this->set('posts', $posts); - } - } - } - -And then in the element we can access the paginated posts model. To -get the latest five posts in an ordered list, we would do something -like the following: - -.. code-block:: php - -

Latest Posts

- requestAction('posts/index?sort=created&direction=asc&limit=5'); ?> -
    - -
  1. - -
- Caching Elements ---------------- From 8c95094fabab83f6b9b36fe8653358db151dc94a Mon Sep 17 00:00:00 2001 From: David Yell Date: Thu, 10 Sep 2015 15:38:41 +0100 Subject: [PATCH 2/2] Tried to create a latex link to another page --- en/views.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/en/views.rst b/en/views.rst index 5e96a31205..5e588f8753 100644 --- a/en/views.rst +++ b/en/views.rst @@ -550,6 +550,8 @@ application, provide a unique cache key value using the following format:: ] ); +If you need more logic in your element, such as dynamic data from a datasource, consider using a View Cell instead of an element, :doc:`find out more about View Cells ` + Caching Elements ----------------