Extending views

This article covers how developers can modify Pagestead views without having to modify the original views. The term “views” refers to template files used within the Model View Controller developer paradigm. To learn more about MVC in general and the views in specific, please have a look at this article. To learn more about views specific to the CodeIgniter framework, please have a look at the official CodeIgniter documentation.

As of Pagestead version 1.0.3, it is possible to implement your own custom views while leaving the original view files fully intact. Pagestead will look for a custom version of each and every view file used, if it finds one it will use the custom version. If it does not find one, it will use the default version.

To implement a custom view, simply duplicate the view file you’re looking to customize. Change the name of the copied view to exactly match the original one, but append an underscore “_” to the filename.

For example, let’s assume you are looking to implement a custom version of the sites.php view file found in /application/modules/sites/views/sites.php. Make a copy of sites.php and name it “_sites.php”. Your customized view file will should be located at /application/modules/sites/views/_sites.php.

Pagestead will now always load your custom _sites.php view file instead of the original file.

Within this custom version of the view file, you are free to implement whatever changes you’d like. However, it is important to realize that if an official update is released which includes changes to the original view file (/application/modules/sites/views/sites.php in the above example), these changes will not automatically be applied in your custom version of the view. Therefor, if you’re using custom views, we suggest you check the file listing all changed files (included with each update) to see if any of the original versions were modified. If so, you will need to make sure you implement the modifications in your custom version of the view (that is assuming you actually want those changes; you’re free to leave them out as well and your application should continue to work just fine).

Was this article helpful?

Related Articles

Leave A Comment?

You must be logged in to post a comment.