1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
<?xml version="1.0" encoding="UTF-8"?>
<!-- Reviewed: no -->
<sect3 id="zend.view.helpers.initial.action">
<title>Action View Helper</title>
<para>
The <classname>Action</classname> view helper enables view scripts to dispatch a
given controller action; the result of the response object following the
dispatch is then returned. These can be used when a particular action
could generate re-usable content or "widget-ized" content.
</para>
<para>
Actions that result in a <methodname>_forward()</methodname> or redirect are
considered invalid, and will return an empty string.
</para>
<para>
The <acronym>API</acronym> for the <classname>Action</classname> view helper follows that of
most <acronym>MVC</acronym> components that invoke controller actions:
<command>action($action, $controller, $module = null, array $params = array())</command>.
<varname>$action</varname> and <varname>$controller</varname> are required; if no
module is specified, the default module is assumed.
</para>
<example id="zend.view.helpers.initial.action.usage">
<title>Basic Usage of Action View Helper</title>
<para>
As an example, you may have a <classname>CommentController</classname> with a
<methodname>listAction()</methodname> method you wish to invoke in order to pull
a list of comments for the current request:
</para>
<programlisting language="php"><![CDATA[
<div id="sidebar right">
<div class="item">
<?php echo $this->action('list',
'comment',
null,
array('count' => 10)); ?>
</div>
</div>
]]></programlisting>
</example>
</sect3>
<!--
vim:se ts=4 sw=4 et:
-->
|