Skip to content

Commit ed8f4e6

Browse files
committed
docs: clarify the use of namespaced views
1 parent dbaf84f commit ed8f4e6

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

user_guide_src/source/outgoing/views.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ example, you could load the **blog_view.php** file from **example/blog/Views** b
104104

105105
.. literalinclude:: views/005.php
106106

107+
.. note:: You must use backslashes (``\``) when referencing namespaced views,
108+
as this is how CodeIgniter distinguishes a namespaced view from a regular
109+
file path. Forward slashes (``/``) are only used for subdirectories within
110+
the standard **app/Views** folder.
111+
107112
.. _views-overriding-namespaced-views:
108113

109114
Overriding Namespaced Views
@@ -151,6 +156,13 @@ To override this view (using the default configuration), create a file at the ma
151156
152157
Now, when you call ``view('Example\Blog\blog_view')``, CodeIgniter will automatically load your custom view from **app/Views/overrides/Example/Blog/blog_view.php** instead of the original module view file.
153158

159+
.. note:: The override path must match exactly how you reference the view.
160+
If you load a view as ``view('Example\Blog\blog_view')``, the override
161+
path is **app/Views/overrides/Example/Blog/blog_view.php**. However,
162+
if you explicitly include the ``Views`` directory in the call, e.g.,
163+
``view('Example\Blog\Views\blog_view')``, the override path must also
164+
include it: **app/Views/overrides/Example/Blog/Views/blog_view.php**.
165+
154166
.. _caching-views:
155167

156168
Caching Views

0 commit comments

Comments
 (0)