Book Image

Building Websites with Mambo

By : Hagen Graf
Book Image

Building Websites with Mambo

By: Hagen Graf

Overview of this book

<p>Mambo is a mature and fully featured Content Management System (CMS). First released in 2001, the system is now on release 4.5.x and is supported by an active and well organized open source development team and community. Mambo is both easy to use at the entry level for creating basic websites, whilst having the power and flexibility to support complex web applications.<br /><br />Mambo implements the core requirements of a full featured CMS. It has a powerful and extensible templating system with the ability to upload and manage many different data types. User access control, content approval, rich administrative control, content display scheduling are all built-in. New features and extensions are constantly added to the core system, with many more being available and supported by the community.<br /><br />The book begins by introducing Mambo and concepts behind content management. Then the installation of Mambo, and its supporting software [Apache/MySQL/PHP] is covered clearly and simply.&nbsp; Once you have the installation up and running, we then take a tour of Mambo as it appears out of the box, to familiarize ourselves with how it works and what is what. As you take the tour, your own ideas for what you need in your new website begin to crystallise around what you can see Mambo is capable of.<br /><br />We then build our web application, using the features of Mambo that are essential to our purpose. We try not to spend time on things that don�??t matter at this point. Once we have a base version of our site up, we then learn how to change its appearance and feature set to suit our particular requirements, including bringing it into line with an established corporate identity. At the end of the book we show how, if you have the skills and the need, you can add your own extensions to Mambo.</p>
Table of Contents (13 chapters)

A.2 Templates


Templates contain many elements. The most important elements are the CSS arrays and the embedded PHP code.

A.2.1 CSS

In different Mambo versions, different names have become ingrained for certain arrays. These arrays are also called classes in CSS. I would like to show you four examples. If a class that does not exist in the CSS file is called, nothing changes in the display. Because of the multiplicity of versions and extensions, you are always well advised to look at the HTML code to get an overview of the classes used.

Head Area

Here you see the CSS definitions (Listing A.1) reflected in the head area and the respective areas on the website (Figure A.1). The CSS code is to serve as an example. Not all areas are provided with CSS examples. Look at the CSS files of predefined templates to find further examples:

Listing A.1: CSS Definitions: Head Area

.title {
font-family: sans-serif;
font-size: 20px;
font-weight: bold;
color: #000000;
margin-left: 10px;
}
.button {
font-family : Verdana, Arial, Helvetica, sans-serif;
font-style : normal;
font-size : 10px;
font-weight : bold;
background-color : #F0F0F0;
color : #000000;
border : 1px solid #CCCCCC;
}

Figure A.1: Head Area

Menu Area

Here you see the CSS definitions reflected in the menu area (Listing A.2) and in the respective areas of the website (Figure A.2):

Listing A.2: CSS Definitions: Menu Area

table.moduletable th {
font-size : 11px;
font-weight : bold;
color : #000000;
text-align : left;
width : 100%;
letter-spacing: 2px;
text-indent: 5px;
padding-bottom: 3px;
}
a.sublevel:link, a.sublevel:visited {
padding-left: 1px;
vertical-align: middle;
font-size: 11px;
color: #ff6600;
text-align: left;
}
a.sublevel:hover {
color: #ff9e31; text-decoration: none;
}
a.mainlevel:link, a.mainlevel:visited {
display: block;
color: #ffffff;
font-weight: bold;
background-image: url(../images/menu_bgr.png);
background-repeat: no-repeat;
width: 95%;
text-indent: 15px;
text-decoration: none;
font-family: Verdana, Helvetica, Arial, sans-serif;
line-height: 20px;
margin-bottom: 1px;
}
a.mainlevel:hover {
color: #333333;
}
.inputbox {
font-family : Verdana, Arial, Helvetica, sans-serif;
font-size : 10px;
color : #000000;
background-color : #F0F0F0;
border : 1px solid #CCCCCC;
}
a:link, a:visited {
color: #ff6600;
text-decoration: none;
}
a:hover {
color: #ff3300;
text-decoration: underline;
}

Figure A.2: Menu Area

Content Elements

Here you see the CSS definitions (Listing A.3) reflected in the content area and in the respective areas of the website (Figure A.3):

Listing A.3: CSS Definitions: Content Element

.createdate {
font-family : Arial, Helvetica, sans-serif;
font-size : 10px;
color : #999999;
text-align : left;
}
.contentheading {
font-family : Verdana, Arial, Helvetica, sans-serif;
font-size : 12px;
font-weight : bold;
color : #ff9900;
text-align : left;
}
.small {
font-family : Verdana, Arial, Helvetica, sans-serif;
font-size : 10px;
color : #999999;
text-decoration : none;
font-weight : bold;
}
.contentpane {
background : #dedede;
}
tr, td, p, div {
font-family : Verdana, Arial, Helvetica, sans-serif;
font-size : 11px;
color : #333333;
}

Figure A.3: Content Elements

News Overview

Here you see the CSS definitions (Listing A.4) reflected in the News overview and in the respective areas of the website (Figure A.4):

Listing A.4: CSS Definitions: News Overview

.sectiontableheader {
background-color : #CCCCCC;
color : #333333;
font-weight : bold;
}
.sectiontableentry1 {
background-color : #F0F0F0;
}

Figure A.4: News Overview

A.2.2 PHP and Other Modules in index.php

PHP code

Action

<?php

First line

defined( ‘_VALID_MOS’ ) or die ( ‘Direct Access to this location, is not allowed.’ );
$iso = explode( ‘=’, _ISO )
echo ‘<?xml version="1.0" encoding="’. $iso[1] .’"?’ .’>’;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1 /DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/ 1999/xhtml">

Here, direct access to the file is suppressed and the correct XHTML header is defined

HEAD

 

<?php mosShowHead(); ?>

Creation of the metatags is defined as in Global Configuration

if ( $my->id ) {
initEditor()
}

Initialization of the WYSIWYG editor

<meta http-equiv="Content-Type" content="text/html;
<?php echo _ISO; ?>" />

Specification of the correct content type

<link href = "<?php echo $mosConfig_live_site; ?>/templates/rhuk_solarflare_ii/css /template_css.css"
rel="stylesheet" type="text/css"/>

Setting of the CSS file

BODY

 

<?php mosPathWay(); ?>

The path of the page

mosLoadModules ( ‘[ort]’, [, $style])

Loading of the module at the position of [ort]. If $style is given, its meaning is:

0 Module is displayed as a column in a table (<td>…</td>)

1 Module is displayed horizontally in a cell.

-1 Module is displayed without surrounding table.

-2 Module is displayed in the barrier-free xMambo format (<div>…</div>).

mosCountModules( ‘[ort]’ )

Counting of the modules at position [ort]

<?php mosMainBody(); ?>

Content area

<?php include_once( $GLOBALS[ ‘mosConfig_ absolute_path’ ] . ‘/includes/footer.php’ ); ?>

Footer

Table A.2: PHP Module in index.php