While these instructions are installation instructions, they require you to already have installed the basic version of the Cheats Database client already, if you have not done that please click here to find out how.
Several different advanced implementations are discussed here, and some may apply and some many not, please note however none of these are compulsory and they are all optional from each other, you do not need to implement them all once one is done.
Contents:
You can limit a website to a single platform fairly easily through the user interface of this website, however once you have done that your website will only display one platform throughout the website in your navigation bar which is a bit of a waste of a click for your users, this article will explain how to remove this bar and how to implement a global alphabet so your users can browse through your website.
If you haven’t already done so, you will want to limit the number of platforms your websites accepts to a specific one and also reset the caching for your website, all these instructions can be found here.
Once the above is done it is fairly simple to implement the global alphabet, by default the website will already have implemented as soon as you cleared your cache. Now all you need to do is add the alphabet placeholder into your core.html layout:
[[ALPHABET]]
And remove the platforms one:
[[PLATFORMS]]
The website comes with three global items by default, these items are:
In order to remove one or all of these features you need to edit the config.inc.php file again and search for the line:
$aConfig['plugins'] = array('LatestCheats', 'PopularCheats', 'Platforms');
You need to remove parts from the array, so for example, if you no longer want the Platforms plugin to be activated your plugins config line would look like:
$aConfig['plugins'] = array('LatestCheats', 'PopularCheats');
Many website have sitewide dynamic objects, for example they may have a sitewide news that updates infrequently, a list of links that is random or perhaps a random picture.
In this example we will show how to show a couple random links in your templates on each different page load, you should be able to use this example to create your own dynamic template content.
/plugins/Links.php
include_once ABS_ROOT . '/library/plugin.inc.php';
class Plugin_Links extends Plugin
{
function init()
{
$pReg = $this->getReg();
$pTemplate = $pReg->getTemplate();
$aLinks = array ( 'http://www.google.com',
'http://www.cheatsdatabase.com',
'http://www.yahoo.co.uk');
$pTemplate->setTemplate('misc/links.html');
shuffle($aLinks);
$aLinks = array_slice($aLinks, 0, 2, true);
$szHtml = '';
foreach($aLinks as $szLink)
{
$szHtml .= $pTemplate->parse(array('url' => $szLink, 'name' => $szLink));
$pTemplate->reset();
}
$pTemplate->setGlobalReplace('links', $szHtml);
return true;
}
}
The start of this file is pretty simple, it loads the internal file required, and it then loads the class with the init() function initially which loads up some standard variables, $pReg and $pTemplate which are used later on in the script for the templating.
Next there is the following $aLinks code, which basically just builds an array of links to randomly find one of, this is a very simple example and you would probably use mysql or something similar to add these links.
$aLinks = array ( 'http://www.google.com',
'http://www.cheatsdatabase.com',
'http://www.yahoo.co.uk');
Next you have the template portion of the code, this tells the page what file to use as the template for this plugin, this file is then found (by default) in “templates/default/parts/misc/links.html”
$pTemplate->setTemplate('misc/links.html');
Next you have the portion of code that finds 2 random links within the array previously assigned to $aLinks.
shuffle($aLinks);
$aLinks = array_slice($aLinks, 0, 2, true);
Now that we have two links we need to add these links to the template.
$szHtml = '';
foreach($aLinks as $szLink)
{
$szHtml .= $pTemplate->parse(array('url' => $szLink, 'name' => $szLink));
$pTemplate->reset();
}
This code first loops through all of the links and uses the template to parse links into the html container using the placeholders “url” and “name” (which hold the same value but we use multiple to show you the usage), the template is then reset for the next link.
After the above is completed we have the following:
$pTemplate->setGlobalReplace('links', $szHtml);
This code tells the internal template that whenever the text “[[LINKS]]” is found replace it with the links we just built into our html container.
Now, we need to update a template to place these links, we opened up the file /templates/default/core.html and added the text “[[LINKS]]” which was then replaced with our random link upon refresh!
Our “templates/default/parts/misc/links.html” file looked like:
<li><a href='[[URL]]'>[[NAME]]</a></li>
In order to add your own pages to your website you will need to understand at the very least the basics of PHP and also be able to work with a template class.
We have left the index module (/modules/index/) un-obfuscated to use as an example for making your own pages, please take a look at that module to familiarize yourself with the code required, and then see the comments below for some insight to what is behind the code.
Registry code
The registry code below basically is an implementation of a centralized class store, the first line is of no use to you and the second line is simply setting the $pTemplate to work with when working with templates
$pReg = $this->getReg();
$pTemplate = $pReg->getTemplate();
Set the template
This code is fairly obvious, it basically sets a location and reads in the data from the template into the template class, note this is now the template that any further calls will be made upon.
$pTemplate->setTemplate('index/index.html');
Set the title
This code sets a variable which the getTitle function within this class then replies to the core code what the title of the page should be. This code is not required but left inside for example purposes, you may choose to leave this line out and instead return “home” from within the getTitle function further up the page, this will have the exact same expected outcome.
$this->m_szTitle = "Home";
Return HTML
The core functions of the software require a module to return a html string, this would normally be achieved by using the built in outputter within the template class, in theory this page needn’t use the template class at all and the HTML could simply be placed in a variable then
return $pTemplate->__toString();
