You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: user_guide_src/source/changelogs/v4.7.0.rst
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -125,7 +125,7 @@ Libraries
125
125
- **Image:** Added ``ImageMagickHandler::clearMetadata()`` method to remove image metadata for privacy protection.
126
126
- **ResponseTrait:** Added ``paginate``` method to simplify paginated API responses. See :ref:`ResponseTrait::paginate() <api_response_trait_paginate>` for details.
127
127
- **Time:** added methods ``Time::addCalendarMonths()`` and ``Time::subCalendarMonths()``
128
-
- **View:** Added the ability to override namespaced views (e.g., from modules) by placing a matching file structure within the **app/Views** directory. See :ref:`Overriding Namespaced Views <views-overriding-namespaced-views>` for details.
128
+
- **View:** Added the ability to override namespaced views (e.g., from modules/packages) by placing a matching file structure within the **app/Views/overrides** directory. See :ref:`Overriding Namespaced Views <views-overriding-namespaced-views>` for details.
Copy file name to clipboardExpand all lines: user_guide_src/source/outgoing/views.rst
+23-8Lines changed: 23 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -111,10 +111,24 @@ Overriding Namespaced Views
111
111
112
112
.. versionadded:: 4.7.0
113
113
114
-
You can override a namespaced view by creating a matching directory structure within your main **app/Views** directory.
115
-
This allows you to customize the output of modules or packages without modifying their source code.
114
+
You can override a namespaced view by creating a matching directory structure within your application's **app/Views** directory.
115
+
This allows you to customize the output of modules or packages without modifying their core source code.
116
116
117
-
For example, assume you have a module named Blog with the namespace ``Example\Blog``. The original view file is located at:
117
+
Configuration
118
+
-------------
119
+
120
+
By default, overrides are looked for in the **app/Views/overrides** directory. You can configure this location via the ``$appOverridesFolder`` property in **app/Config/View.php**:
121
+
122
+
.. code-block:: php
123
+
124
+
public string $appOverridesFolder = 'overrides';
125
+
126
+
If you prefer to map namespaces directly to the root of **app/Views** (without a subdirectory), you can set this value to an empty string (``''``).
127
+
128
+
Example
129
+
-------
130
+
131
+
Assume you have a module named **Blog** with the namespace ``Example\Blog``. The original view file is located at:
118
132
119
133
.. code-block:: text
120
134
@@ -124,17 +138,18 @@ For example, assume you have a module named Blog with the namespace ``Example\Bl
124
138
└── Views
125
139
└── blog_view.php
126
140
127
-
To override this view, create a file at the matching path within your application's Views directory:
141
+
To override this view (using the default configuration), create a file at the matching path within **app/Views/overrides**:
128
142
129
143
.. code-block:: text
130
144
131
145
/app
132
146
└── Views
133
-
└── Example <-- Matches the first part of namespace
134
-
└── Blog <-- Matches the second part of namespace
135
-
└── blog_view.php <-- Your custom view
147
+
└── overrides <-- Configured $appOverridesFolder
148
+
└── Example <-- Matches the first part of namespace
149
+
└── Blog <-- Matches the second part of namespace
150
+
└── blog_view.php <-- Your custom view
136
151
137
-
Now, when you call ``view('Example\Blog\blog_view')``, CodeIgniter will automatically load your custom view from **app/Views/Example/Blog/blog_view.php** instead of the original view file.
152
+
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.
0 commit comments