Difference between revisions of "Projects/kde.org/Capacity HOWTO"

Jump to: navigation, search
m (use path template for files and <code>... for variables)
Line 23: Line 23:
  
 
==The magic site.inc==
 
==The magic site.inc==
For each subsite, a site.inc in the toplevel directory of this page,
+
For each subsite, a {{path|site.inc}} in the toplevel directory of this page,
 
which would be equal to the later documentroot on the server in many
 
which would be equal to the later documentroot on the server in many
cases, may be created. This include is used by the header.inc, it
+
cases, may be created. This include is used by the {{path|header.inc}}, it
 
should contain some information about your site, like it's name
 
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
 
and the email address of the webmaster, this will be used by header/footer
Line 48: Line 48:
 
   ?>
 
   ?>
  
Even in the site.inc you can already use the i18n-functions,
+
Even in the {{path|site.inc}} you can already use the i18n-functions,
 
which is important to have the names right on translated pages!
 
which is important to have the names right on translated pages!
  
 
==Global Variables setup by header.inc==
 
==Global Variables setup by header.inc==
The header.inc does some setup of global vars, even before it includes
+
The {{path|header.inc}} does some setup of global vars, even before it includes the {{path|site.inc}}, these are:
the site.inc, these are:
+
  
 
   $site_root
 
   $site_root
Line 60: Line 59:
 
   $current_relativeurl
 
   $current_relativeurl
  
* site_root contains the relative path to the toplevel of the current site, like:
+
* <code>$site_root</code> contains the relative path to the toplevel of the current site, like:
 
   $site_root = "../.."
 
   $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:
+
* <code>$document_root</code> 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"
 
   $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 http://127.0.0.1:8080/sites/www, like it is for staging, this would contain
+
* <code>$url_root</code> contains the absolute baseurl to the toplevel of your site, if your site would for example have a it's toplevel in http://127.0.0.1:8080/sites/www, like it is for staging, this would contain
 
   $url_root = /sites/www
 
   $url_root = /sites/www
  
* current_relativeurl contains the relative part of the current url to the url_root, would you access http://127.0.0.1:8080/sites/www/whatiskde/manifest.php and /sites/www is the url_root, it would contain
+
* <code>$current_relativeurl</code> contains the relative part of the current url to the url_root, would you access http://127.0.0.1:8080/sites/www/whatiskde/manifest.php and /sites/www is the <code>$url_root</code>, it would contain
 
   $current_relativeurl = whatiskde/manifest.php
 
   $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 header.inc, this won't work now, as the header.inc will overwrite the site_root. This should cause no danger, as header.inc should find out the right one, but in the long term, all manual definitions should be removed, the global variables header.inc exports should be used to replace the usage of the old site_root.
+
'''BE AWARE:''' In former version of the framework it was common to set the <code>$site_root</code> manually before including the {{path|header.inc}}, this won't work now, as the {{path|header.inc}} will overwrite the <code>$site_root</code>. This should cause no danger, as {{path|header.inc}} should find out the right one, but in the long term, all manual definitions should be removed, the global variables {{path|header.inc}} exports should be used to replace the usage of the old <code>$site_root</code>.
  
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:
+
The framework is clever, it will never add trailing slashs to the <code>$site_root</code>, <code>$document_root</code> and <code>$url_root</code>, therefor they can and must always be used like:
 
   $some_url = "$site_root/mycoolpage.php"
 
   $some_url = "$site_root/mycoolpage.php"

Revision as of 08:44, 5 October 2006

Contents


Introduction

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:

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

The magic site.inc

For each subsite, a site.inc 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 header.inc, 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 site.inc would be:

 <?php
   // promote which subdomain we are
   // we are www.kde.org 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 site.inc you can already use the i18n-functions, which is important to have the names right on translated pages!

Global Variables setup by header.inc

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

 $site_root
 $document_root
 $url_root
 $current_relativeurl
  • $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 http://127.0.0.1:8080/sites/www, 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 header.inc, this won't work now, as the header.inc will overwrite the $site_root. This should cause no danger, as header.inc should find out the right one, but in the long term, all manual definitions should be removed, the global variables header.inc 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"

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V.Legal