User Tools

Site Tools


nupusi:olatedownload:custom

Olate Download Customisation

Unlike previous versions of Olate Download v2.x, version 3.x comes fully equiped with a template system which allows you to customise your site exactly how you want it. The template files are plain HTML, and therefore an understanding of HTML is needed. There are also other special tags which are parsed by the template engine to insert the data.

Templates

Creating a template

To make a new theme, follow the steps below. Alternatively, download templates created by other users in the Olate forums.

  1. From the templates folder in your installation, copy the olate folder and rename it to the name of your template.
  2. Edit or recreate each template file with the HTML for your design. It is best to start with global/core.tpl.php, as this acts as a 'wrapper' and appears on all pages.
  3. Once all the files have been modified to suit your design, select your theme from the corresponding box in the General Settings section of the admin control panel. You can also do this while editing the files, as it is easier to see the changes you have made.

Modifying the default theme

If you like the default Olate theme, but would like to change the colours and logo to suit your design, you can edit the CSS file which is located at global/core.css. To change the logo, simply replace the following file with your own logo: images/logo.gif

Important templates

  • global/core.tpl.php - The wrapper which is shown on all pages, the actual content replaces the $page_content variable in this template.
  • global/core.css - The CSS file for the default template. This can change depending on the theme in use.
  • global/categories.tpl.php - This is the first template which is shown in the content area - it shows a list of all the categories.
  • admin/start.tpl.php - The equivalent of categories.tpl.php for the Admin CP. This is the first template to be shown, and shows the Admin CP menu.

Variables

Variables are used to insert dynamic data from Olate Download - the name of a file, for example.

They have a very simple syntax: {$variable_name}

Global Variables

There are a number of variables that are available in any template, these are:

  • {$global_vars[exec_time]} - The total execution time of the page you are viewing
  • {$global_vars[queries]} - The amount of MySQL queries needed to generate the page
  • {$global_vars[version]} - The version of Olate Download you are running
  • {$global_vars[request_uri]} - The URL that was requested to generate the page
  • {$global_vars[php_self]} - The filename of the PHP script handling the request
  • {$post_vars[x]} - Any variables passed in from a POST request (Replace x with the name)
  • {$get_vars[x]} - Same as above, but with variables passed in through the URL
  • {$user_permissions[x]} - An array containing the currently logged in user's permissions (Replace x with the permission name, value will be either 1 or 0)

Language Variables

Language variables can change depending on the language file that is currently being used.

{lang:section_name:variable_name}

For instance, if {lang:general:title} was put in a template, it would use the following variable in the language file:

$language['text']['general']['title']

Pagination

You can place {$pagination} on the page in certain files to display the pagination there. This allows you to move it about to suit your own design.

This variable is available in the following fields:

  • categories/files.tpl.php
  • search/search.tpl.php
  • files/toolbox.tpl.php
  • display/all.tpl.php

Blocks

Blocks can be used to create repeating sections of a template easily and quickly.

The syntax is:

{block:block_name}
Hello {$name}!<br />''
{/block:block_name}

To parse this, you could use something similar to this:

<?php
$names = array('Matt', 'David');
foreach (s $names as $name){
$template->assign_var('name', $name);
$template->use_block('block_name');
}
?>

Which would show the following:

Matt
David

Conditionals

Conditionals are a very useful part of the template engine, and enable you to show a different page depending on the value of a certain condition. If you are familiar with programming languages, then you will know what conditionals are, and the OD3 template engine supports the following features:

  • if ()
  • elseif ()
  • else
  • endif

Conditional statements can use any variables that are available to the template, and certain functions (isset(), empty()) in the condition. Here are some examples:

{if:$global_vars[version]=='3.0.0 Beta 1'}
You are using an old version!
{elseif:empty($name)}
Who are you?
{else}
What do we do now?
{endif}

Languages

Olate Download 3 includes a full language system which allows you to create your own language files. The default language is English (British).

Many users have already contributed and provided their translated language files. These can be found at http://www.olate.co.uk/od3/download.php.

The language file is located in upload/languages/english.php. Within this file, you will find all of the text used within Olate Download 3. You should rename this file to the name of your new translation.

Lines 20 to 28 are basic configuration options to allow you to change the name of the language and add your name, e-mail address and web address. You should also define which Olate Downlad version the language file is for as well as the date you finished the translation.

Note: The short_name variable must be the same as the filename.

The actual translation is simply a matter of replacing the english text on the right side with the translated version.

Once you are done, you can select the new language from the General Settings option of the Admin Control Panel.

Please consider releasing the file to other users to download and use - e-mail it to us and we will announce it and offer it for download and can mention your website in a credit line!

nupusi/olatedownload/custom.txt · Last modified: 2008/12/06 13:56 (external edit)