Skip to content

Commit fab5398

Browse files
authored
Merge pull request #8521 from kenjis/docs-view-and-view-renderer
docs: improve view() and view renderer
2 parents 924407f + 0cec717 commit fab5398

File tree

3 files changed

+28
-14
lines changed

3 files changed

+28
-14
lines changed

user_guide_src/source/general/common_functions.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,8 @@ Service Accessors
197197

198198
.. literalinclude:: common_functions/004.php
199199

200-
For more details, see the :doc:`Views </outgoing/views>` page.
200+
For more details, see the :doc:`Views <../outgoing/views>` and
201+
:doc:`../outgoing/view_renderer` page.
201202

202203
.. php:function:: view_cell($library[, $params = null[, $ttl = 0[, $cacheName = null]]])
203204

user_guide_src/source/outgoing/view_renderer.rst

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,18 @@ View Renderer Options
116116

117117
Several options can be passed to the ``render()`` or ``renderString()`` methods:
118118

119-
- ``cache`` - the time in seconds, to save a view's results; ignored for renderString()
120-
- ``cache_name`` - the ID used to save/retrieve a cached view result; defaults to the viewpath; ignored for ``renderString()``
121-
- ``saveData`` - true if the view data parameters should be retained for subsequent calls
122-
123-
.. note:: ``saveData()`` as defined by the interface must be a boolean, but implementing
119+
- ``$options``
120+
121+
- ``cache`` - the time in seconds, to save a view's results; ignored for
122+
``renderString()``.
123+
- ``cache_name`` - the ID used to save/retrieve a cached view result; defaults
124+
to the ``$viewPath``; ignored for ``renderString()``.
125+
- ``debug`` - can be set to false to disable the addition of debug code for
126+
:ref:`Debug Toolbar <the-debug-toolbar>`.
127+
- ``$saveData`` - true if the view data parameters should be retained for
128+
subsequent calls.
129+
130+
.. note:: ``$saveData`` as defined by the interface must be a boolean, but implementing
124131
classes (like ``View`` below) may extend this to include ``null`` values.
125132

126133
***************

user_guide_src/source/outgoing/views.rst

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ Then save the file in your **app/Views** directory.
3737
Displaying a View
3838
=================
3939

40-
To load and display a particular view file you will use the following code in your controller:
40+
To load and display a particular view file you will use the :php:func:`view()`
41+
function like following code in your controller:
4142

4243
.. literalinclude:: views/001.php
4344
:lines: 2-
@@ -64,8 +65,10 @@ If you visit your site, you should see your new view. The URL was similar to thi
6465
Loading Multiple Views
6566
======================
6667

67-
CodeIgniter will intelligently handle multiple calls to ``view()`` from within a controller. If more than one
68-
call happens they will be appended together. For example, you may wish to have a header view, a menu view, a
68+
CodeIgniter will intelligently handle multiple calls to :php:func:`view()` from
69+
within a controller. If more than one call happens they will be appended together.
70+
71+
For example, you may wish to have a header view, a menu view, a
6972
content view, and a footer view. That might look something like this:
7073

7174
.. literalinclude:: views/003.php
@@ -101,8 +104,8 @@ example, you could load the **blog_view.php** file from **example/blog/Views** b
101104
Caching Views
102105
=============
103106

104-
You can cache a view with the ``view()`` function by passing a ``cache`` option with the number of seconds to cache
105-
the view for, in the third parameter:
107+
You can cache a view with the :php:func:`view()` function by passing a ``cache``
108+
option with the number of seconds to cache the view for, in the third parameter:
106109

107110
.. literalinclude:: views/006.php
108111
:lines: 2-
@@ -116,7 +119,9 @@ along ``cache_name`` and the cache ID you wish to use:
116119
Adding Dynamic Data to the View
117120
===============================
118121

119-
Data is passed from the controller to the view by way of an array in the second parameter of the ``view()`` function.
122+
Data is passed from the controller to the view by way of an array in the second
123+
parameter of the :php:func:`view()` function.
124+
120125
Here's an example:
121126

122127
.. literalinclude:: views/008.php
@@ -142,8 +147,9 @@ Then load the page at the URL you've been using and you should see the variables
142147
The saveData Option
143148
-------------------
144149

145-
The data passed in is retained for subsequent calls to ``view()``. If you call the function multiple times
146-
in a single request, you will not have to pass the desired data to each ``view()``.
150+
The data passed in is retained for subsequent calls to :php:func:`view()`. If you
151+
call the function multiple times in a single request, you will not have to pass
152+
the desired data to each ``view()``.
147153

148154
But this might not keep any data from "bleeding" into
149155
other views, potentially causing issues. If you would prefer to clean the data after one call, you can pass the ``saveData`` option

0 commit comments

Comments
 (0)