diff --git a/en/views.rst b/en/views.rst index 45dba5f4bc..5e588f8753 100644 --- a/en/views.rst +++ b/en/views.rst @@ -550,47 +550,7 @@ 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. - -
+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 ----------------