Views
Note: This page is an extension of the CodeIgniter User Guide page of the same name. Please read the CodeIgniter Views page in addition to this page for complete information about this feature.
CoolBrew extends the views system by allowing view files to be overridden. In other words, when you load a view, CoolBrew will look for the view file in three different folders and use the first one it finds:
- DOCPATH/views/MODULE_NAME/
- system/views/MODULE_NAME/
- system/modules/MODULE_NAME/views/
Please Note: To avoid running into a problem when multiple modules use the same view filename, view files in the system-level and document-level views folders are stored in folders named according to the module they come from. So while module-level view files are stored in system/modules/MODULE_NAME/views/, the system-level and document-level view files would be stored in system/views/MODULE_NAME/ and DOCPATH/views/MODULE_NAME/ respectively.
System-wide Default Views
A views folder has been added to the system level folder so that you can set up system-wide default views without having to edit the modules' default view files. This might make it easier to update modules as new versions are released. For example, to override the sample-view.php view file from the sample module, you would copy the module's default view file into the system-level views folder:
system/views/sample/sample-view.php
You can then make changes to the copy of sample-view.php and that changed view will become the default view for all your websites.
Note: If the module organizes its view files in subfolders inside it's views folder, make sure to recreate those subfolders when copying the view files.
Customizing Views for Each Website
If you don't like how one or more of the default views look on any of your websites, you can customize those views by placing copies of the view files into the document root of the websites you want to change. This gives you complete control over how each website looks. For example, to override the sample-view.php view file from the sample module, you would copy the module's default view file into the document-level views folder:
DOCPATH/views/sample/sample-view.php
You can then make changes to the local copy of sample-view.php and that changed view will display on that website only.
Note: If the module organizes its view files in subfolders inside it's views folder, make sure to recreate those subfolders when copying the view files.
Customized Views for CodeIgniter Applications
The same system is in operation when you are running a standard CodeIgniter application, so you can override those view files in the same way you would override a module's views. Since you can't have an application with the same name as a module, there shouldn't be any problem with folders conflicting inside the system-level or document-level views folders.
Specifying a Different View File
In many cases, you can specify a different template name as part of the tag in cases where you may want to use the same tag in two different places -- and with two different looks -- on the same website. For example, if you wanted to use a different template name with the menu.left_menu tag, it would look like this:
<?php get("menu.left_menu", $menu_id, 2, false, 'different_left_menu.tpl'); ?>