Some users of phpVMS often look for a way to add pages within the system without using the pages editor as sometimes it will break php code you are trying to use in the page. It can be done easily by creating a quick module to show the pages.
For this example we will create a module named “Content” to display our custom pages for our phpVMS system.
First create a new folder in your /core/modules folder named Content (case sensitive) and inside of that folder create a blank php file named Content.php
Extend the core codon structure to start the module file,
<?php
class Content extends CodonModule {
}
Next create the index function within the class that the module will default to if there is no method declared in the url call.
function index() {
}
Within the index function create a call to show your custom template (view) for your site.
$this->show('customfile');
Your Custom.php module (controller) file should look similar to this now,
<?php
class Content extends CodonModule {
function index() {
$this->show('customfile');
}
}
Next, create your custom template (view) by creating a file in your skin folder named customfile.tpl . This file should contain everything that you want shown on the page you are creating. This file is the part of your webpage that is contained in between the <body> and the </body> tags. The header and footer as well as all the css and js calls made in your template will also be included within this page, so no need to create new links to any of those items. You can use html or php or a combination of both within this file. An example might be;
<h1>My Custom Content Page</h1> <ul> <li>List Item 1</li> <li>List Item 2</li> <li>List Item 3</li> </ul>
To view this page create a link on your site pointing to the module;
http://www.mysite.com/index.php/content
If you would like to add more pages to the module it can be done by using additional methods within the module(class). For example you could add a page for staff members;
<?php
class Content extends CodonModule {
function index() {
$this->show('customfile');
}
function staff() {
$this->show('staff');
}
}
Then, create a file in your skin folder named staff.tpl and once again include the html and/or php code you want included in the page. To reach this page on your web site, add the method name to the end of the url we used earlier,
http://www.mysite.com/index.php/content/staff
You can pass data in variables from the core system using these methods if it is required and also add access controls if needed.







One Comment
Thank you so much for this! You rock!!!