Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 09/03/17 in all areas

  1. 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'. Controllers About In phpVMS, which is developed on the Codon Framework, all controllers are located in the following directory. /core/modules/<module name> http://www.myva.com/index.php/something routes to the index function of the respective controller located core/modules/Something/Something.php (More on this later) Naming 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: /core/modules/Profile and contains the file Profile.php which is the controller. Views About 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. Naming 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. Models About The models are located in the core/common directory. They are the database layer and handle all requests to the database. Naming 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: <?php class About extends CodonModule { function index () { $this->render('about.tpl'); } function mission () { $this->render('about_mission.tpl'); } } ?> 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! http://forum.phpvms....and-add-ons-r25 http://forum.phpvms....conventions-r17
    1 point
×
×
  • Create New...