Projects/ HOWTO

< Projects‎ |
Revision as of 09:12, 9 October 2006 by Cullmann (Talk | contribs) (app info..)

Jump to: navigation, search


Capacity is a versatile framework which helps you to construct your page by focusing on the content. Your pages will be simple PHP-files which include predefined header and footer. This header/footer layout the page, you only provide the real content and menu structure.

Example PHP-file

Any normal page just contains:

   $page_title = "Page Title";
   include "";
 Content of the web page
 <?php include ""; ?>

The magic

For each subsite, a in the toplevel directory of this page, which would be equal to the later documentroot on the server in many cases, may be created. This include is used by the, it should contain some information about your site, like it's name and the email address of the webmaster, this will be used by header/footer to setup the page correct.

An example would be:

   // promote which subdomain we are
   // we are in this case!
   $site = "www";
   // use new style ;) yeah
   $templatepath = "newlayout/";
   // promote title to use
   $site_title = i18n_var("K Desktop Environment");
   // links in the top bar, right
   $menuright = array ('family/'=>'Sitemap',
     'contact/'=>'Contact Us');

Even in the you can already use the i18n-functions, which is important to have the names right on translated pages!

Global Variables setup by

The does some setup of global vars, even before it includes the, these are:

  • $site_root contains the relative path to the toplevel of the current site, like:
 $site_root = "../.."
  • $document_root contains the absolut pathname which is the documentroot of this site, even correct if the site isn't in it's own vhost, example:
 $document_root = "/home/www/sites/www"
  • $url_root contains the absolute baseurl to the toplevel of your site, if your site would for example have a it's toplevel in, like it is for staging, this would contain
 $url_root = /sites/www
 $current_relativeurl = whatiskde/manifest.php

BE AWARE: In former version of the framework it was common to set the $site_root manually before including the, this won't work now, as the will overwrite the $site_root. This should cause no danger, as should find out the right one, but in the long term, all manual definitions should be removed, the global variables exports should be used to replace the usage of the old $site_root.

The framework is clever, it will never add trailing slashs to the $site_root, $document_root and $url_root, therefor they can and must always be used like:

 $some_url = "$site_root/mycoolpage.php"

Configuration Variables

You can set some variables to alter the behaviour of the framework, either global in your or in front of your inclusion in each .php-files.

Useful variables are:

  • The Name for your whole subdomain/site, best set once in
 $site_title = "KDE Foo Site Title";
  • The title of the individual page.
 $page_title = "Page Title";
  • Don't show edit function on the page. The default is $showedit = true;. This setting should normally not be used. is the preferred place.
 $showedit = false;

Online Editing

Capacity features online editing and previewing of changes.

You can make and preview changes of existing pages online by clicking on the [edit] link at the bottom of each page. Try it on this page. Then you can download you changes and commit them yourself via SVN, or you can click the link to email a unified diff to the web team.

Menu Definitions

The navigation menu is defined by a number of files. They are included by a function in media/includes/classes/, which is called from media/includes/ The general menu structure is defined in the file of the root directory of each KDE subsite (e.g. or

It should look like this:

   $this->setName ("KDE Foo Site Title");
   $section =& $this->appendSection("Inform");
   $section->appendLink("KDE Home","",false);
   $section =& $this->appendSection("A Second Menu Section");
   $section->appendDir("A Subdirectory","subdirectory");
   $section->appendLink("A Single Page","singlepage.php");

Each mentioned subdirectory will then also be searched for a file to define a submenu (e.g.

The format is similar:

   $this->appendDir("A Subsubdirectory","subsubdirectory");
   $this->appendLink("A Page in the Subdirectory","singlepage.php");

The content of subsubdirectories is currently not added to the menu, but this may change in future. If a subdirectory has just the index.php file or a submenu for the subdirectory is not desired, then an empty can be added. If the is missing, then the subdirectory is be treated like having an empty file.


The main headline of a page is defined via $page_title. If a page has several sections with a headline each, <h2> is used for them (<h3> for subsections):

 <h2><a name="section1" />Section Headline<h2> 
 <h3>Subsection Headline<h3> 

Headlines must never be used to increase the size of a text. Use <b> to make it stick out. The first letters of every word of a headline or link should be capitalized, apart from small words like "a", "to", etc.

To allow better navigation through the site, each <h2> heading should be linked from a quicklinks section on top of the page:

 <div id="quicklinks"> [ 
   <a href="section1">Section Headline</a> | 
   <a href="section2">Second Section Headline</a> | 
   <a href="section3">Third Section Headline</a> ] 

If you wish to link <h3> headlines as well, then you can use:

 <div id="quicklinks"> 
   <b><a href="section1">Section Headline</a></b>: <br /> [ 
   <a href="section11">Subsection Headline</a> | 
   <a href="section21">Second Subsection Headline</a> | 
   <a href="section31">Third Subsection Headline</a> ] 
   <b><a href="section2">Second Section Headline</a></b>: <br /> [ 
   <a href="section21">Subsection Headline</a> ] 


A PHP class has been written to make it easy to write FAQs. It will always give a consistent formatting style. Using the class is simple:

   $faq = new FAQ();
   $faq->addQuestion("This is the text of the question",
     "This is the text of the answer");

Note: the page won't be rendered until you call show(). Please use this class rather than hand constructing a FAQ to save your time and to improve consistency.

Image Galleries

A PHP class has been written to make it easy to write image galleries. The image galleries can link to enlarged versions of the image, but this isn't compulsory. Using the class is simple:

   $gallery = new ImageGallery("Add a summary for screen readers here");
   $gallery->addImage("pics/image_sm.png", "pics/image.png", "640", "480",
     "Alt text", "Image caption (top)", "Image description (bottom)");
   $gallery->addImage("pics/image_sm.png",  0, "640", "480",
     "Alt text", "Image caption (top)", "Image description (bottom)");

The first call to addImage() creates an image that can be clicked on to link to a larger version of the image. startNewRow() creates a new row. The second call to addImage() creates an image that isn't clickable (note the 0 rather than the URL to the large image).

The parameters of addImage() are as follows:

 addImage($src_url, $dest_url, $width_pixels, $height_pixels,
   $alt_text, $caption_text, $description_text)
  • $src_url - The URL of the thumbnail image. If it is empty (""), then only caption and description will be shown.
  • $dest_url - The URL of the enlarged version of the image

The caption and the description will be links as well if $dest_url is specified.

  • $width_pixels - The width of the image in pixels
  • $height_pixels - The height of the image in pixels
  • $alt_text - A short description of the image for use in the alt="" tag (used by non-graphical browsers and screen readers)
  • $caption_text - A short caption which will appear above the image in bold (optional)
  • $description_text - A short description of the image which will appear underneath (optional)

Note: the page won't be rendered until you call show(). Please use this class rather than hand constructing an image gallery to save your time and to improve consistency.

Application Information Page

For web sites like and it makes sense to have a sub-directory for each program that is part of the project and in that sub-directory have a page which shows information about the program. The AppInfo class has been designed to make it easy to create such a page. It can be used as follows:

   $appinfo = new AppInfo("KWord");
   $appinfo->setIcon( "pics/hi48-app-kword.png", "48", "48");
   $appinfo->setCopyright("1998", "the KWord Team");
   $appinfo->addAuthor("Reginald Stadlbauer", "");
   $appinfo->addAuthor("Torben Weis", "");
   $appinfo->addContributor("David Faure", "");
   $appinfo->addContributor("Thomas Zander", "");
   $appinfo->addContributor("Shaheed Haque", "");
   $appinfo->addContributor("Laurent Montel",
   $appinfo->addContributor("Sven Lüppken", "");

The second and third parameters of setIcon() are the width and height of the icon. The addContributor() function can take an optional third parameter, a short description of the person's function in the project.