Documentation: Overall Template

From UniLang Wiki

Jump to: navigation, search

We will provide a template here that can serve as that basis for a new UniLang page and will use it to explain the general structure of any UniLang page.

The Template

The lines are numbered for convenience:

0 <?
1 require("settings.php");
2 require($styledir . "/loadlanguage.php");
3 $pagetext = loadlanguage("pagename",$lang);
4 require($styledir . "/header.php");
5 require($styledir . "/flags.php");
6 $countname = "__pagename"; require($styledir . "/count.php");
7 ?><CENTER><TABLE CLASS="content"><TR><TD><BR>
...
 <H1 CLASS="<? echo $pillar; ?>"><? printtext($pagetext,'title'); ?></H1>
...
8 </TD></TR></TABLE></CENTER><BR><BR><BR>
9 <? require($styledir . "/footer.php"); ?>

The above template makes use of the LANG-system, as most UniLang pages do. We will discuss the lines one by one now:

  • 1: Loads ./settings.php (present in any directory), which in turn loads /globalsettings.php, together they are responsible for initializing a whole bunch of variables:
    • Variables that contain URLs and Directories, so using static URLs in files is not necessary and highly discouraged (e.g $baseurl, $mainurl, $styleurl_static, $flagurl_static, $basedir, $maindir, $styledir, $flagdir
    • Variables containing passwords (encrypted of course) and mysql-data.
    • Language variable $lang
    • Debug information

Every UniLang page starts with this.

  • 2: This loads the functions necessary for the LANG-system, needed for having a page in multiple languages.
  • 3: This is an example loading the strings from the LANG-page named "pagename" in the requested language (which is always $lang). You should obviously let this refer to your LANG-file.
  • 4: This loads the header, this includes the HTML HEAD with all its META keys, and all then necessary JavaScripts and Cascading Style Sheets. There is room for customizing by setting any of the following variables before loading header.php:
    • $pillar: Can be set to "org" (default),"res","com","dev" or "gad" and corresponds to the pillar this page is in. The pillar in turn determines the entire colour scheme (red, blue,green,yellow, purple) of the page. Use this!
    • $appendtitle: This contains text that will be appended to the default title "UniLang Community". It's highly recommended to use this!
    • $othertitle: This will contain text that the title will be set to. It's highly discouraged to use this!
    • $otherdescription: Contains a description (META) of the page which will replace the default description.
    • $otherkeywords: Contains keywords (META) for the page which will replace the default keywords.
    • $norobots: set this to 1 if you want robots (from search engines) not index this page, and not to follow any links from it. Set it to 2 if you do want them to follow links, but not to index, set it to three if you do want them to index, but not to follow links. Leaving it unset will default to the page being indexed and links being followed.
    • $othercss: can be set to an extra CSS file to load, use this if you need to load an extra CSS file. The CSS file has to be located in the styles/ directory.
    • $overridecss: can be set to an extra CSS file to load, use this if you need to load an extra CSS file. The CSS file can be anywhere on the web.
    • $otherjs: can be set to an extra JS file to load, the JS file can be anywhere on the web
    • $extraheaders: This contains text that will literally be dumped as such in the HTML HEAD, so use this if you need any other user-defined things in the header
    • $noheaders: Won't print the usual headers if set to 1
  • 5: This loads the flag-bar you see on the left. If you do not want a flagbar, set $noflags to 1 before loading this, but do load it anyway!
  • 6: This sets the variable $countname contains a unique name (it's a strange convention to start with two underscores) that identifies the page in the statistics. Including /main/count.php ensures this page will be counted in the statistics. Always use this!
  • 7: This initializes the table for the actual page content. If you don't put this page margins will be ugly.
  • Between line 8 and 9 is the actual content of the page, this is an example that demonstrates always to set a CLASS="<? echo $pillar; ?>" for H1, H2, H3, H4 etc.. This example also illustrated the use of a LANG file for multilingual support. See

the documentation on the LANG-system for more information on this.

  • 8: This end the table for the actual page content. If you don't put this and did put line 7, layout will be messed up.
  • 9: This adds the footer and has to be included on the last line of the page. If you don't want headers and footers, then set $noheaders to 1 (discouraged!), but do include these scripts.



.

Personal tools

« Return to the main site