HOME TIPS FORUMS DOWNLOADS
   »»  Tips Archive |
Tricks/Tools : How XOOPS Renders Pages You Are Viewing
Posted by tl001 on 2007/6/5 11:10:00 (4820 reads)

An article by Ignacio Segura, "nachenko" www.pensamientosdivergentes.net
thanks to davidl2 and wtravel for reviewing.

In this article we'll explain how the URL you wrote in the address bar became the nice page you're viewing at this moment.

XOOPS is a content management system (CMS for short). Such those systems allow two things:
1 - Provides visitors the look and content of the website, and
2 – Gives the webmaster the tools to manage this content.

There are many different systems out there, free and commercial, but all them work in similar ways. They get the contents from their database, put it together in a design template and send the whole burrito to the visitor. The differences among CMS is not what they do, but how they do it.

So how does it work? How has XOOPS provided you this article you're reading?

The "what": Collecting the content


First thing to get is the content. An article, a list of products, photos... once we get it, we'll manage the problem of showing it to the user.

The URL you can read in your browser's address bar points to a PHP file. The first two things this file does are:

1 – Loads XOOPS config file: "mainfile.php". Now the script "knows" what is needed to locate a file or an entry in the database.

2 – Loads "header.php". This file then runs XOOPS engine.

At this point we still have to collect the content, but this is done in two separate processes. One process states what blocks are visible for this visitor (that is, you) at this address, and goes block after block to get their contents.

The other process gets the "main" content (that is, this article). In XOOPS, there's always a "main" content, a content that is not inside blocks. There's an exception to this rule, but that's all, just one: the starting page.
We won't talk about this "main" content, or the blocks, as every module does it it's own way. The only thing you have to know at this moment is that both the "blocks process" and the "main content process" do the same thing when they end: deliver all the info collected to the template engine.



The "how": assembling the content in a template


In XOOPS, templates are simply HTML files that include special "markers" (we call them Smarty tags) to tell the system where to put the content. A “piece of template” for an article could be something like this:
<h1><{$article.title}></h1>
<p><strong><{$article.abstract}></strong></p>
<hr/>
<div><{$article.text}></div>


Embedded in the HTML code, these red items are the tags that will be replaced by the appropiated content. The title of the article, the abstract, the text... Something named "template engine" makes the replacing. There are many template engines out there. XOOPS uses Smarty (smarty.php.net). This engine can do a lot of things, but this is not the scope of this article. The only thing we want you to know at this moment is the difference between a Smarty tag and a HTML tag.

· This is a HTML tag:
· This is a Smarty tag: <{tag}>
· This is a variable into a Smarty tag: <{$variable}>

Notice the { } symbols. The <{ and }> is used to identify a Smarty tag.

Enough about markers. Let's talk about the templates. In XOOPS, blocks can have 8 different locations around the main content. In the default theme, they are organized this way:





You see, blocks surround the main content. It's a cascade structure: theme file calls:
1 – A CSS file that controls everything.
2 – Main content template.
3 – A template for every block location, and these load every block's template.


The appropiate Smarty tags are then replaced. The page is finished and ready to be shown to the visitor.

That's all!

Printer Friendly Page Send this Story to a Friend
The comments are owned by the poster. We aren't responsible for their content.
Poster Thread
tl001
Posted: 2007/6/5 11:27  Updated: 2007/6/5 11:27
Webmaster
Joined: 2004/6/10
From:
Posts: 282
 Re: How XOOPS Renders Pages You Are Viewing
nachenko, thank you for sharing an excellent article.

One thing about mainfile.php - if you have separate programs or functions, you can pre-load them by adding a line into mainfile.php

By adding the following line into mainfile.php
 include "simplified_url.php";

we are telling xoops to load simplified_url.php file, thus all our URLs (almost all! ) are transformed into short URLs.