//
// arbplate - An Easy and Powerful Template System v0.8a
//
// Copyright (c) 2001, Paul Arbogast
//
//
// Latest version is available at http://arbplate.sourceforge.net
// Send Questions or comments to arbo@att.net
//
Copyright (C) 2001 Paul Arbogast
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
------------------------------------------------------------
Setting up your Database:
arbplate, hopefully before long, will support most databases. Currently, I only
support mysql. Next up is support for a flat file database system that you can
use SQL queries on, for those that have service providers that do not provide
database access.
To create the required tables, use included *.sql file.
Currently, arbplate only uses two tables, one for site variables and one for
site links, when user authentication is worked into the system, more will
be used.
Creating your site with arbplate:
Create your index.php file for the site:
---------
<?php
include ( "class.arbplate.php" ) ;
set_arberr();
$arb = new arbplate ( );
if ( ! ( isset( $tn ) ) ) {
$tn = $ARB_CONFIG['DEF_INDEX'];
}
$arb -> parse ( "$tn" );
unset_arberr();
?>
---------
Now you ask, "That's great, but what about the templates?"
First off, the templates must be in a specified directory. The default for the
system, is "./template/arbplate".
Let me show you a basic site, starting with index.arb (the default template):
---------
{inc}heading.arb{/inc}
<body>
{inc}header.arb{/inc}
{inc}indexpage.arb{/inc}
{inc}footer.arb{/inc}
</body>
</html>
---------
Now the heading.arb template:
---------
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>{var}site{/var}</title>
<meta name="description" content= "{var}description{/var}" />
<link rel="StyleSheet" href="{var}ROOT_DIR{/var}{var}SKIN{/var}.css" type="text/css" media="screen" />
</head>
---------
Now, if you notice, you will see a few {var}...{/var} tags. These do variable substitution. 'site' and
'description' are defined by the user in index.php as above, or in a database if you set_db(true) like the
second index.php above.
The variables ROOT_DIR and SKIN are simply static variables of the class, in this case, used to build a
path/filename to our stylesheet file for the related theme (skin).
The next file that index.arb will load is header.arb:
---------
<table width="100%">
<tr>
<td>
<img src="{var}sitegif{/var}" alt="{var}description{/var}" />
</td>
<td class="header">
<a href="{link}l:home{/link}">{link}d:home{/link}</a> | <a href="{link}l:difpg{/link}">{link}d:downloads{/link}</a>
</td>
</tr>
</table>
---------
This loads the normal header (as I have defined it), loading my graphic (sitegif, which is defined like all other
variables).
You may notice the link stuff. I have taken sort of a different approach to links. I create multi-demensional
arrays holding a link name, where the link points, and a description. You don't need to use the link description,
I could have simply had:
<a href="{link}l:home{/link}">Home</a>
But I figured it would be easier to change, say from 'Home' to 'Main' if you do it like I did, and simply change
your link definition, rather than going through HTML code looking all over for it.
Ah, now comes your main content (indexpage.arb):
---------
<table width="75%" align="center">
<tr>
<td>
<p>This is where you may put your content, or include more templates, generate tables or whatever.</p>
</td>
</tr>
</table>
---------
That one is pretty self explanitory for this most basic of examples, so lets move on to the footer.arb:
---------
<hr />
<center>Questions? Remarks? Just <a href="{link}l:emailme{/link}">email</a> me.</center>
<br />
<br />
<center><p class="sig">arbplate is {var}copyright{/var}</p></center>
---------
That's just about it. If you remember, in the header.arb, we have a link to 'difpg', which is just a second
page set up as an example, but of course, we will need to set up the template files for it, so here is
difpg.arb:
---------
{inc}heading.arb{/inc}
<body>
{inc}header.arb{/inc}
{inc}difpgpage.arb{/inc}
{inc}footer.arb{/inc}
</body>
</html>
----------
HEY! That's the index.arb file! Well, sort of, the only real difference is it includes difpgpage.arb rather
than indexpage.arb. Here's difpgpage.arb:
----------
<table width="75%>
<tr>
<td>
Some content on a different page.
</td>
</tr>
</table>
---------
That's it. Now you have a most basic site. Well, ok, theres the matter of that style sheet that we set up
for the default theme directory, so right now, make arbplate.css in ./template/arbplate:
---------
BODY {
font-family : Veranda, Arial, Helvetica, Sans-Serif;
color : #000000;
background : #ffffff;
}
.sig {
font-size : 8pt;
font-family : sans-serif;
}
.header {
color : orange;
text-align: right;
}
---------
Well, if you have questions, email me, the address is above. I know this is real basic, you can do a LOT more
with the system. Actually, if you keep reading, maybe you'll learn more.
NOW... all those tags and how to do things (in order processed):
{inc}nameoffiletoinclude.ext{/inc}
Simply replaces that tag with the contents of the named file.
{var}variablename{/var}
Replaces tagline with content of variablename as defined (with def_static or in a database),
or the content of any of the class variables (eg. VERSION, ROOT_DIR, etc).
* currently inactivated - updating to make more flexible
* {fill}tablename{/fill}
*
* This will open tablename in mysql and fill an array with the contents of the query
* "select * from tablename".
*
* This will be expanded so you can select database to use, what to search on, and other
* fun things like matching, but it's at it's most basic level now.
*
* As well as filling an array, this tag will be replaced with the number of rows found
* in the SQL query results. This is important because it goes to use in the {rep} tag
* for defining how many repitions to do.
{rep}x:codetorepeatoverandover{/rep}
This tagset is still under construction like the {fill}, it will be a bit more
flexible as I improve it. But basically this is what you have, say you put this
line in your template:
{rep}4:This is iteration @@@@.<br>{/rep}
What you would get is:
This is iteration 0.
This is iteration 1.
This is iteration 2.
This is iteration 3.
The 4: is the count. This can be replaced with the {fill} since {fill} returns a #.
The @@@@ is a placeholder to fill in the iteration number of the loop, this will fall
a bit more into place when we go over {func}.
You can include {inc} or {var} or whatever in a {rep} making it very versitile.
{func}functionname();{/fucn}
This will allow you to get away from including php code in your templates. If you
have a 'common' file of sorts that contains loads of functions you want to include,
simply 'include "functionsfile.php"' after the include for the class file in your
index.php.
Now a function doesn't have to be a function. It basically is eval'd code. So any
valid php code COULD be there, but once again, that defeats the whole purpose, so
just put your stuff in functions and call the function. This provides a greater
seperation of content and layout.
An example using the {rep}:
{rep}10:@@@@ squared is {func}print sqr(@@@@);{/func}<br>{/rep}
would print out:
0 squared is 0
1 squared is 1
2 squared is 1.4142135623731
.. and so on for 10 iterations.
* fill tag inoperative due to construction on it.
*
* There is also a special function used with {rep} and {fill} to build tables from
* Database files. An example:
*
* {rep}{fill}users{/fill}:{func}get_item(@@@@,"email");{/func}<br>{rep}
*
* This would:
*
* - Open table users and return all users (for now, until updated/improved)
* - replicate the code in the rep field x times, x being the number of
* rows found in table users.
* - replace all of the function tagsets with the value of the 'email' field
* from the database for each iteration..
*
* So basically, it would print out every users email address.
*
* Remember, I am going to update this so you can search on specific and such.
{link}A:linkname{/link}
A is either l or d. If you use l, this returns the actual link to location
of the realted linkname you specify. If you use d, it will return the link
description.
To Do:
- finish text db interface
- user authentication system
- add query tag (it's gonna be cool)
- add if tag (gotta have conditionals, right?)
- some other stuff i can't remember at the moment.
|