Skip to content

Commit b66202a

Browse files
authored
Merge pull request #7765 from cakephp/fix-ajaxviewswitch
Update docs for requesthandler replacement.
2 parents 3a7d8f8 + 12d36a2 commit b66202a

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

en/controllers.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,22 @@ view logic::
374374
It is important to remember that match-all views are applied only *after*
375375
content-type negotiation is attempted.
376376

377+
Using AjaxView
378+
==============
379+
380+
In applications that use hypermedia or AJAX clients, you often need to render
381+
view contents without the wrapping layout. You can use the ``AjaxView`` that
382+
is bundled with the application skeleton::
383+
384+
// In a controller action, or in beforeRender.
385+
if ($this->request->is('ajax')) {
386+
$this->viewBuilder()->setClassName('Ajax');
387+
}
388+
389+
``AjaxView`` will respond as ``text/html`` and use the ``ajax`` layout.
390+
Generally this layout is minimal or contains client specific markup. This
391+
replaces usage of ``RequestHandlerComponent`` automatically using the
392+
``AjaxView`` in 4.x.
377393

378394
Redirecting to Other Pages
379395
==========================

en/views.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ Another example, using if/elseif/else. Notice the colons:
117117
<h3>Hi unknown user</h3>
118118
<?php endif; ?>
119119
120-
If you'd prefer using a templating language like
121-
`Twig <https://twig.symfony.com>`_, a subclass of View will bridge your
122-
templating language and CakePHP.
120+
If you'd prefer to use a templating language like
121+
`Twig <https://twig.symfony.com>`_, checkout the `CakePHP Twig Plugin
122+
<https://github.com/cakephp/twig-view>`__
123123

124124
Template files are stored in **templates/**, in a folder named after the
125125
controller that uses the files, and named after the action it corresponds to.

0 commit comments

Comments
 (0)