Jump to content

Developing Custom Pages/Modules and MVC

Recommended Posts

Some people asked me how do I create the custom modules/pages (however you would like to call them )

For example the recruitment page ( http://www.airserbia...php/recruitment )

It is actually really easy but for people who are new with PHP and MVC pattern ( like me not long ago ) it can be quite challenging to understand.

First off, there is good documentation on this matter but not many people take a look there unfortunately.

First of, MVC.

The MVC pattern is really easy to describe. You 'separate' your code in three different sections/files.

Models, Views, Controllers (MVC)

Models are in charge for work with the database, the views are what are displayed to the end user and the controllers control the entire 'application'.



In phpVMS, which is developed on the Codon Framework, all controllers are located in the following directory.

 /core/modules/<module name> 


routes to the index function of the respective controller located


(More on this later)


All folders should be named with the first letter in uppercase. The controller itself should also be named with the first letter in uppercase. Lets take an example

For example, the controller for the Profile is located here:


and contains the file Profile.php which is the controller.



The views are located in the core/templates folder. They contain the HTML output shown to the end user. Any logic should be in the controller not the view file.


All views belonging to a single module should be named with the module name first followed by an _ and a description of the view's purpose.

For example mymodule_showeverything or mymodule_newsomething.



The models are located in the core/common directory. They are the database layer and handle all requests to the database.


Models and are named with the first letter in uppercase. The models end with .class.php (SiteData.class.php).


So, we covered that, let's go to the actual creating of our first module. Let's use the About Us page for example.

Create a new folder inside the

core/modules directory

.Name it About and create a new php file inside called About.php

Once completed, the About.php file should look like this:

class About extends CodonModule
function index ()
function mission ()


Let's take a look what we have done here

First of we extend the CodonModule and create a new index function. This is the function that is loaded when no further functions are appended to the url.

Inside that function we call the view with the $this->render() command. If your view is located in a subfolder you need to add that ( ex. $this->render('subfolder/view.tpl') )

Than we have the mission function which loads the respective view file and can be found with this link: /index.php/about/mission

This is the basic concept to get you up and running.

Please do take a look at the documentation for more information!



  • Like 4

Share this post

Link to post
Share on other sites


That is an awesome tutorial, if you want, I can pin the topic for you. I don't also very see people use the docs mostly.

Well Done! ;)

Share this post

Link to post
Share on other sites

Thank you very much Kyle! It means a lot coming from you!

Yes that would be really nice if you can pin it!

I hope it will help out a lot of new users as it took me a while to figure everything out!

Share this post

Link to post
Share on other sites

Sava, just so you know, I went to your site http://www.airserbiavirtual.com/index.php/recruitment and selected "Continue", and then on the next page under "If you have read the requiremets and the recruitment page please proceed and fill out your application." I selected recruitment page link to go back, and I got this:

[b]Warning[/b]: call_user_func_array() [[url="http://www.airserbiavirtual.com/index.php/recruitment/site_url/index.php/recruitment/function.call-user-func-array"]function.call-user-func-array[/url]]: First argument is expected to be a valid callback, 'Recruitment::site_url' was given in [b]/home/skysim/public_html/airserbia/core/classes/MainController.class.php[/b] on line [b]218[/b]

Most people would NOT do that but for some reasoin I did :) Just thought I would mention it.

Share this post

Link to post
Share on other sites

Yeap. Seems like I messed up the URL. Its an easy fix. I'll fix it as soon as I can.

Thanks for the heads up Bruce. Appreciate it.

Share this post

Link to post
Share on other sites

Instead of


You can use:


And it will work fine with both .php and .tpl phpVMS versions.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now