diff --git a/user_guide_src/source/general/common_functions.rst b/user_guide_src/source/general/common_functions.rst index 75d2cbebd13c..bebf3cb3eaad 100755 --- a/user_guide_src/source/general/common_functions.rst +++ b/user_guide_src/source/general/common_functions.rst @@ -197,7 +197,8 @@ Service Accessors .. literalinclude:: common_functions/004.php - For more details, see the :doc:`Views ` page. + For more details, see the :doc:`Views <../outgoing/views>` and + :doc:`../outgoing/view_renderer` page. .. php:function:: view_cell($library[, $params = null[, $ttl = 0[, $cacheName = null]]]) diff --git a/user_guide_src/source/outgoing/view_renderer.rst b/user_guide_src/source/outgoing/view_renderer.rst index 618a90c4a516..06e15a809e00 100644 --- a/user_guide_src/source/outgoing/view_renderer.rst +++ b/user_guide_src/source/outgoing/view_renderer.rst @@ -116,11 +116,18 @@ View Renderer Options Several options can be passed to the ``render()`` or ``renderString()`` methods: -- ``cache`` - the time in seconds, to save a view's results; ignored for renderString() -- ``cache_name`` - the ID used to save/retrieve a cached view result; defaults to the viewpath; ignored for ``renderString()`` -- ``saveData`` - true if the view data parameters should be retained for subsequent calls - -.. note:: ``saveData()`` as defined by the interface must be a boolean, but implementing +- ``$options`` + + - ``cache`` - the time in seconds, to save a view's results; ignored for + ``renderString()``. + - ``cache_name`` - the ID used to save/retrieve a cached view result; defaults + to the ``$viewPath``; ignored for ``renderString()``. + - ``debug`` - can be set to false to disable the addition of debug code for + :ref:`Debug Toolbar `. +- ``$saveData`` - true if the view data parameters should be retained for + subsequent calls. + +.. note:: ``$saveData`` as defined by the interface must be a boolean, but implementing classes (like ``View`` below) may extend this to include ``null`` values. *************** diff --git a/user_guide_src/source/outgoing/views.rst b/user_guide_src/source/outgoing/views.rst index 70bbadcc7504..fabd811de87a 100644 --- a/user_guide_src/source/outgoing/views.rst +++ b/user_guide_src/source/outgoing/views.rst @@ -37,7 +37,8 @@ Then save the file in your **app/Views** directory. Displaying a View ================= -To load and display a particular view file you will use the following code in your controller: +To load and display a particular view file you will use the :php:func:`view()` +function like following code in your controller: .. literalinclude:: views/001.php :lines: 2- @@ -64,8 +65,10 @@ If you visit your site, you should see your new view. The URL was similar to thi Loading Multiple Views ====================== -CodeIgniter will intelligently handle multiple calls to ``view()`` from within a controller. If more than one -call happens they will be appended together. For example, you may wish to have a header view, a menu view, a +CodeIgniter will intelligently handle multiple calls to :php:func:`view()` from +within a controller. If more than one call happens they will be appended together. + +For example, you may wish to have a header view, a menu view, a content view, and a footer view. That might look something like this: .. literalinclude:: views/003.php @@ -101,8 +104,8 @@ example, you could load the **blog_view.php** file from **example/blog/Views** b Caching Views ============= -You can cache a view with the ``view()`` function by passing a ``cache`` option with the number of seconds to cache -the view for, in the third parameter: +You can cache a view with the :php:func:`view()` function by passing a ``cache`` +option with the number of seconds to cache the view for, in the third parameter: .. literalinclude:: views/006.php :lines: 2- @@ -116,7 +119,9 @@ along ``cache_name`` and the cache ID you wish to use: Adding Dynamic Data to the View =============================== -Data is passed from the controller to the view by way of an array in the second parameter of the ``view()`` function. +Data is passed from the controller to the view by way of an array in the second +parameter of the :php:func:`view()` function. + Here's an example: .. 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 The saveData Option ------------------- -The data passed in is retained for subsequent calls to ``view()``. If you call the function multiple times -in a single request, you will not have to pass the desired data to each ``view()``. +The data passed in is retained for subsequent calls to :php:func:`view()`. If you +call the function multiple times in a single request, you will not have to pass +the desired data to each ``view()``. But this might not keep any data from "bleeding" into other views, potentially causing issues. If you would prefer to clean the data after one call, you can pass the ``saveData`` option