For now, all we need to use is the execute() method.
Creating the View
The class name should be in this format ActionnameViewtype View. Again Actionname is the name of the action in the module. Viewtype is the view type that was passed to the controller in the action. Both Actionname and Viewtype are capitialized. This is a list of the predefined view file types and their naming convention.
Internal Name Class and File Name
Mojavi 2 users ; the naming convention and doc on the file has changed slightly. Before there was an underscore between Actionname and Viewtype. Now, there is no underscore in between, and the Viewtype is capitialized.
For this example, I called my view FirstSuccessView and named the file FirstSuccessView.class.php.
Here’s the code
class FirstSuccessView extends PHPView
* Execute any presentation logic and set template attributes.
public function execute ()
// set our template
// set the title
$this->setAttribute(’title’, ‘Getting Started First Test Page’);
// set the message that is to be passed
$this->setAttribute(’passedData’, ‘Hello World!’);
You also need a template to display the information. I stayed with the naming convention and called my file FirstSuccess.php.
Here is the code for that please note that asp extension files will not work unless you have already created a master template.
This is the result of my first test. I have created a module, action, view and
template. I have successfully passed data from the view to the template.This is what I passed:
That is all for now.
Notice at the first and last line I include a header.php and footer.php. I used this to show how you could have a uniform look across the entire site and how you could do that. Mojavi uses a global template directory in your webapp directory. It is defined as MO_TEMPLATE_DIR and it called templates. I added the following files to the includes sub-directory in the global template directory.
Wrapping it up
Finally, there are a couple of ways you can test this module. Make sure to test in various browsers like firefox which use xpi extensions for their add-ons. The first and quickest way is just to instruct the controller using the url. Just add the module and action. Here’s what it would look like http://yourserver.com/index.php?module=Test&action=First.
The second way is by changing the default module in the settings.ini file in the webapp/config directory.
Under [.actions] you will find the default module. Find the following two lines and change the default module and action.
DEFAULT_MODULE = “Default”
DEFAULT_ACTION = “Index”
After you change the default module and action it should look like this
DEFAULT_MODULE = “Test”
DEFAULT_ACTION = “First”
You are now ready to test your code. Just point your browser to the index.php and see the fruit of your labor.