GenieGate, Version 1.1.0 (PHP 5) manual

An explanation of view files

Abstract

Although GenieGate has used the so-called Model-View-Controller design pattern since it's inception, the view system has been greatly improved. It is now possible to alter views to PHP files of your choosing. For the most part, this section can be skimmed over, it is relevant to those who are trying to alter the HTML.

You may have noticed mysterious files in ~/geniegate/conf/view/, these are view configuration files and allow you to use GenieGate with alternate screens, menus and email messages. It is also possible to reuse PHP files with different parameters for different contexts. This is useful if you only want to alter the text of a few things in what would otherwise be an identical php file.

These configuration files are standard XML documents containing the elements global-forwards and action. You may recognize the general idea if you have ever used a Jakarta Struts application.

The global-forwards section configures views that apply to all the actions, such as login screens and error messages. While the action elements configure views for specific actions.

These elements contain one or more named forward sections. A forward section sets up parameters for a particular view through the use of... Param elements.

Example 7.1. Example view file


<GenieGate>
<global-forwards>
	<forward name="login">
		<Param name="file"  value="GenieGate/views/users/new-user.php" />
		<Param name="shell" value="GenieGate/views/users/shell.php" />
	</forward>
</global-forwards>

<action method="do_show_signup_form">
	<forward name="ok">
		<Param name="file"  value="GenieGate/views/users/user-signup.php" />
		<Param name="shell" value="GenieGate/views/users/shell.php" />
	</forward>
</action>
<action method="do_process_signup">
	<forward name="error">
		<Param name="file"  value="GenieGate/views/users/error-signup.php" />
		<Param name="shell" value="GenieGate/views/users/shell.php" />
	</forward>
	<!-- This is sent through email.  -->
	<forward name="mail" class="GenieGate_View_Mail" require="GenieGate/View/Mail.php">
		<Param name="file" value="GenieGate/views/users/mail-confirm.php" />	
	</forward>
</action>
</GenieGate>

	

  • global-forward

    This sets up global views for logging in, the view is named "login" (The name="login" attribute) This view will display the file GenieGate/views/users/shell.php which expects a parameter called "file" set to GenieGate/views/users/new-user.php

    The parameters are determined by the Param elements. Each parameter contains the name and a value attribute. In this case we have two parameters, one called "file" the other called "shell".

  • <action method="do_show_signup_form">

    This sets up one view for the do_show_signup_form method. Just as within the global-forwards section except that the shell.php will display a different PHP file.

    If you needed to change the shell template for this particular view, you could change it without affecting the other forwards.

  • <action method="do_process_signup">

    This sets up a couple views (called "forward"'s to make Jakarta Struts people feel more at home)

    • error

      This sets up a specific error view for do_process_signup. If you had a forward of the same name in the global-forwards section, you could override it here, to provide a specific screen to display errors during the signup process.

    • mail

      This warrants a bit more explanation, in addition to the name attribute, it supplies class and require attributes.

      You may have guessed from looking at the filename that this is some how related to email, your guess would be correct. The class specifies a PHP class name that implements the required GenieGate_View methods, the require attribute specifies which PHP file contains this class. In this case, the view is for email messages.

      When the class and require attributes are not specified, they default to GenieGate_View_Php and GenieGate/View/Php.php respectively.

If you choose, you may change the locations of these view configuration files in your ~/geniegate/conf/geniegate.ini Look in the Views section for details.