Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update docs for requesthandler replacement. #7765

Merged
merged 1 commit into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions en/controllers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,22 @@ view logic::
It is important to remember that match-all views are applied only *after*
content-type negotiation is attempted.

Using AjaxView
==============

In applications that use hypermedia or AJAX clients, you often need to render
view contents without the wrapping layout. You can use the ``AjaxView`` that
is bundled with the application skeleton::

// In a controller action, or in beforeRender.
if ($this->request->is('ajax')) {
$this->viewBuilder()->setClassName('Ajax');
}

``AjaxView`` will respond as ``text/html`` and use the ``ajax`` layout.
Generally this layout is minimal or contains client specific markup. This
replaces usage of ``RequestHandlerComponent`` automatically using the
``AjaxView`` in 4.x.

Redirecting to Other Pages
==========================
Expand Down
6 changes: 3 additions & 3 deletions en/views.rst
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ Another example, using if/elseif/else. Notice the colons:
<h3>Hi unknown user</h3>
<?php endif; ?>

If you'd prefer using a templating language like
`Twig <https://twig.symfony.com>`_, a subclass of View will bridge your
templating language and CakePHP.
If you'd prefer to use a templating language like
`Twig <https://twig.symfony.com>`_, checkout the `CakePHP Twig Plugin
<https://github.com/cakephp/twig-view>`__

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