@@ -37,7 +37,8 @@ Then save the file in your **app/Views** directory.
37
37
Displaying a View
38
38
=================
39
39
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:
41
42
42
43
.. literalinclude :: views/001.php
43
44
:lines: 2-
@@ -64,8 +65,10 @@ If you visit your site, you should see your new view. The URL was similar to thi
64
65
Loading Multiple Views
65
66
======================
66
67
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
69
72
content view, and a footer view. That might look something like this:
70
73
71
74
.. literalinclude :: views/003.php
@@ -101,8 +104,8 @@ example, you could load the **blog_view.php** file from **example/blog/Views** b
101
104
Caching Views
102
105
=============
103
106
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:
106
109
107
110
.. literalinclude :: views/006.php
108
111
:lines: 2-
@@ -116,7 +119,9 @@ along ``cache_name`` and the cache ID you wish to use:
116
119
Adding Dynamic Data to the View
117
120
===============================
118
121
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
+
120
125
Here's an example:
121
126
122
127
.. 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
142
147
The saveData Option
143
148
-------------------
144
149
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() ``.
147
153
148
154
But this might not keep any data from "bleeding" into
149
155
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