MSU Masthead

Metlab CourseLib cl/site Basic Page

cl/site

This page describes how to create a basic page in the CourseLib system. A basic page includes the CourseLib system and styles.

This is a basic CourseLib page template:

<?php
require 'site.php';
$view = new CL\Site\View($site);
$view->title = 'Page Template';
?>
<!DOCTYPE html>
<html>
<head>
<link href="cl/site.css" type="text/css" rel="stylesheet" />
<?php echo $view->head(); ?>
</head>

<body>
<?php echo $view->header(); ?>

<p>Page content</p>

<?php echo $view->footer(); ?>
</body>
</html>

THis assumes the page is in the site root directory. Adjust the path to site.php and cl/site.css as appropriate. For example if the page is in directory that is a child of the root directory, those statements become:

require '../site.php';

<link href="../../cl/site.css" type="text/css" rel="stylesheet" />

A note about views

This example uses the view CL\Site\View. Other views are available in the site library and are installed by additional components. If cl/users is installed, it is recommended that CL\Users\View be utilized for pages, since it provides extended capabilties. If cl/course is installed, it is recommended that CL\Course\View be utilized.

A note about cl/site.css

It is not required that cl/site.css be included. The view will automatically include site.css and any other requires stylesheets. In fact, the view will filter this line out. However, it makes it much easier to edit pages in the site using tools such as Dreamweaver, when the actual stylesheet is included.

CourseLib retains a conventional HTML page structure to make it easier to author content using tools like Dreamweaver. It would be easy to have the PHP generate all content, including the DOCTYPE, html, head, and body tags. However, retaining this structure makes editing much easier. This is a fundamental philosophy of CourseLib.