@@ -19,7 +19,7 @@ Using the example controller you created in the controller page, let’s add a v
1919Creating a View
2020===============
2121
22- Using your text editor, create a file called ``BlogView .php `` and put this in it::
22+ Using your text editor, create a file called ``blog_view .php `` and put this in it::
2323
2424 <html>
2525 <head>
@@ -53,7 +53,7 @@ Now, open the controller file you made earlier called ``Blog.php``, and replace
5353 {
5454 public function index()
5555 {
56- echo view('BlogView ');
56+ echo view('blog_view ');
5757 }
5858 }
5959
@@ -107,11 +107,11 @@ You can store views under a **View** directory that is namespaced, and load that
107107PHP does not support loading non-class files from a namespace, CodeIgniter provides this feature to make it possible
108108to package your views together in a module-like fashion for easy re-use or distribution.
109109
110- If you have ``Blog `` directory that has a PSR-4 mapping set up in the :doc: `Autoloader </concepts/autoloader >` living
110+ If you have ``example/blog `` directory that has a PSR-4 mapping set up in the :doc: `Autoloader </concepts/autoloader >` living
111111under the namespace ``Example\Blog ``, you could retrieve view files as if they were namespaced also. Following this
112- example, you could load the **BlogView ** file from **/blog/views ** by prepending the namespace to the view name::
112+ example, you could load the **blog_view.php ** file from **example /blog/Views ** by prepending the namespace to the view name::
113113
114- echo view('Example\Blog\Views\BlogView ');
114+ echo view('Example\Blog\Views\blog_view ');
115115
116116Caching Views
117117=============
@@ -140,7 +140,7 @@ Here's an example::
140140 'message' => 'My Message',
141141 ];
142142
143- echo view('blogview ', $data);
143+ echo view('blog_view ', $data);
144144
145145Let's try it with your controller file. Open it and add this code::
146146
@@ -155,7 +155,7 @@ Let's try it with your controller file. Open it and add this code::
155155 $data['title'] = "My Real Title";
156156 $data['heading'] = "My Real Heading";
157157
158- echo view('blogview ', $data);
158+ echo view('blog_view ', $data);
159159 }
160160 }
161161
@@ -184,7 +184,7 @@ into the `$option` array in the third parameter.
184184 'message' => 'My Message',
185185 ];
186186
187- echo view('blogview ', $data, ['saveData' => true]);
187+ echo view('blog_view ', $data, ['saveData' => true]);
188188
189189Additionally, if you would like the default functionality of the view function to be that it does save the data
190190between calls, you can set ``$saveData `` to **true ** in **app/Config/Views.php **.
@@ -212,7 +212,7 @@ Here’s a simple example. Add this to your controller::
212212 'heading' => 'My Real Heading',
213213 ];
214214
215- echo view('blogview ', $data);
215+ echo view('blog_view ', $data);
216216 }
217217 }
218218
0 commit comments