[prev in list] [next in list] [prev in thread] [next in thread] 

List:       quanta
Subject:    Re: [Quanta] Templates and snippets
From:       "Greg Rundlett" <greg.rundlett () gmail ! com>
Date:       2007-06-19 2:03:18
Message-ID: 5e2aaca40706181903v6327e268udf192c285ce44f04 () mail ! gmail ! com
[Download RAW message or body]

What I hear you asking is better answered by explaining how to do this
in PHP...  Creating easy to maintain and update websites is a snap
using basic 'file includes'.

First create your 'include files' (hash lines are for illustration only)

##########  begin /inc/header.php ##########
<html>
<head>
<title><?php echo $title; ?></title>
<meta name="keywords" content="<?php echo $keywords; ?>"/>
</head>
<body>
########## end file ######################


##########  begin /inc/nav.php ##########
 <ul class="navigation_menu">
  <li>menu1</li>
  <li>menu2</li>
  <li>menu3</li>
  <li>menu4</li>
 </ul>
########## end file ######################

##########  begin /inc/footer.php ##########
<?php echo "&copy; " . date(%Y)
</body>
</html>
########## end file ######################




The each of your content files would look something like this:
############   begin template.php #################
<?php

/**
 * This file is based on template.php
 * To create a new file, start with template.php
 * Save it as a new file and begin your work there
 * All variable content should be modified
 */
// php variables
$title = 'Contact Us';
$keywords = 'contact, connect, help, support';

include ('/inc/header.php');
include ('/inc/nav.php');
?>

 <div class="left_column_context_navigation">
 <!-- start variable content -->
   variable HTML content
 <!-- end variable content -->
 </div>
 <div class="center_column_context_navigation">
 <!-- start variable content -->
   variable HTML content
 <!-- end variable content -->
 </div>

<?php
include ('/inc/footer.php');
?>
########## end file ######################


More tutorials can be found at
http://www.w3schools.com/php/php_includes.asp
http://www.stevedawson.com/article0012.php
and the php.net manual http://www.php.net/include/


Now, you can save these files as regular files on your filesystem and
call it a day.  Any time you need to update the actual content, it's a
matter of changing that content.  Any time you want to modify the
'header' or footer, you edit those files.  All content files that
include those files are instantly updated.

Using Quanta's notion of templates, you can save these files into
Quanta's template managing infrastructure which simply lets you
organize, manipulate and insert your templates into new files on a
project-focused basis.  I've never found much advantage to that over
simply organizing my templates on the filesystem, but ymmv.

As you explore the possibility to use variables and includes, you will
come across a host of templating solutions beyond the intrinsic
capabilities of PHP.  The most well know are probably Smarty for the
'sandboxed' type of template system and PHPTemplate (of Drupal) for
the pure PHP template type http://drupal.org/project/phptemplate

-- 
A: Yes.
> Q: Are you sure?
>> A: Because it reverses the logical flow of conversation.
>>> Q: Why is top posting annoying in email?
_______________________________________________
Quanta mailing list
Quanta@mail.kde.org
https://mail.kde.org/mailman/listinfo/quanta
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic