Paintings and drawings portfolio

Tuesday, January 5, 2010

XNova Legacies 2009.2: Menu and template management


The purpose of this quick howto is to describe the way XNova manages templates and language files (I have not found docs about this on the official board).

This example adds an entry in the XNova main menu.

Clicking on this new entry will display a simple table with two columns.


XNova Template & menu management Version: 1.0
5.1 KiB 2116 Downloads Details...


Adding a menu entry

Edit \xnova\templates\OpenGame\left_menu.tpl and add a link (ex: {Test})

<td colspan="2"><div><a href="test.php" target="{mf}">{Test}</a></div></td>

Add the entry language

French is used in this example.

Edit \xnova\language\fr\ and add the {Test} translation (ex: “Nom du lien”)

$lang['Test']           = 'Test';

Describe the fields used by the script

Create \xnova\language\fr\ and describe the values used in the script.

$lang['Field1']    = "Field 1";
$lang['Field2']    = "Field 2";

Create a template which will be displayed to users

Create \xnova\templates\OpenGame\test.tpl and define the page structure, with  the position of the fields set up in

<table style="text-align: left; width: 750px;" border="0" cellpadding="0" cellspacing="1">

Script creation

Create \xnova\test.php

Include the common variables:

define('INSIDE' , true);
define('INSTALL' , false);
require_once dirname(__FILE__) .'/common.php';

Include the language file defined at step 3:


Initialize the page and fields data variables:

$page    = "";
$parse    = $lang;

Fill the fields used in your template in an array. In this example, sample strings are used.

$parse['Field1'] = "Champ 1";
$parse['Field2'] = "Champ 2";

Build the page by giving this array to your template created at step 4:

$page = parsetemplate(gettemplate('test'), $parse);

Display the page in “User mode” (viewable by everyone):

display($page, $lang['test'], false);

Files list

  • \xnova\templates\OpenGame\left_menu.tpl
  • \xnova\language\fr\
  • \xnova\language\fr\
  • \xnova\templates\OpenGame\test.tpl
  • \xnova\test.php
posted by asphyx at 17:55  

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

You must be logged in to post a comment.

Powered by WordPress