Jump to content
xisto Community
Sign in to follow this  
jlhaslip

Templating System Using Php Includes Building a Dynamic site using Includes and flat-files.

Recommended Posts

Php based Templating System

 

 

http://forums.xisto.com/no_longer_exists/

 

The Source Code for the scripts are included (literally) on the different pages on the Demo, including the Contact / Email script. The only page not there yet is the Message Script. Maybe tonight I will upload that.

 

This one uses a little bit of query-string checking to confirm that the contents of the page are actually available (file_exists())and an allowed page content before serving it up. The 'allowed page content' is done by checking against a flat-file containing an array of acceptable query-string contents. I had another part of the script working to check against the contents of the third column of the menu_data.txt file, but it fails on the Xisto server and I haven't sourced the problem, yet, so this array check is a temporary measure.

 

Also, there is a Conact, or email script which writes to a text file as a repository for messages received from the site in case for some reason the Mail() doesn't work for the Hosting service. (ie: Xisto.net disables the mail() on the Free Hosting Accounts) I have written a script to extract and print them also, maybe a Tutorial about that will be next?

 

Also, I have used a 'fixed' header and sidebar approach to the template design which some of you might find interesting. There is a conditional statement there to utilize a different css file for the page structure of IE, due to the Browser differences, this was the way to make it 'cross-browser friendly'. Since I don't have an IE6 Browser, I will only state that the responses I have received are positive. I haven't actually seen the page in an IE6 Browser yet, so I don't know if it explodes or not. If the Alt= for the menus are removed, the page validates to the w3c standards set in the DTD. (html 4 strict).

 

Can someone tell me if IE6 still requires the Alt= for tooltips? Or can they be removed and have the title= displayed instead?

 

Anyway, thanks Vujsa over at Xisto for his original topic(CMS 101). I found it quite valuable as a guide to learning the php required for this scripting and it has opened up an entirely new perspective on the Web Sites I intend to build in the next short while. I hope someone else might be encouraged by this sample I have added to the Topic. And as Vujsa stated up in his Topic ay Xisto, the greatest advantage of viewing these codes and Templates is not in 'sniping' the code to install the files as a website, although it is possible to do that, the greatest value to be received is as an enticement to proceed on the path to learn the language and develop an understanding of the uses for the tools which php provide. If you want to use the code, PM or email me and I'll zip a set to you, but you wil receive much more benefit from writing your own Templating System. And it will be easier to modify or maintain because you are familiar with the parts, what they do and how they operate. Having said that, if you want / need a copy of the code, let me know and I'll pass you the zip file.

 

Thanks for showing some interest in my scripts.

Share this post


Link to post
Share on other sites

Can someone tell me if IE6 still requires the Alt= for tooltips? Or can they be removed and have the title= displayed instead?

IE6 uses both the alt and title attributes for tooltips. If the alt attribute is present however, IE will take preference to it and use it as a tooltip but if it isn't, it will use the title attribute. Ie:

 

[hr=shade]

 

<a href="/" title="Aunty Mauvais"> <img src="Image2.gif" alt="Johnny"></a>

[/hr]

 

Will show Johnny as the tooltip

 

<a href="/" title="Aunty Mauvais"> <img src="Image2.gif"></a>

 

Will show Aunty Mauvais as the tooltip

 

<a href="/" title="Aunty Mauvais"> <img src="Image2.gif" alt=""></a>

 

Will show no the tooltip [hr=shade][/hr]

Share this post


Link to post
Share on other sites

Okay, then I will remove the Alt= from the scripting on the templates. I have been mistaken about them for a while. I thought IE still required them and ignored the title=. That is good. Won't be long and the template up there will validate without changes. Thanks, Electric Ink.

Share this post


Link to post
Share on other sites

Before you remove the ALT tags, wouldn't you be better to leave both the TITLE and ALT tags, with the same text, so older versions of IE will still see the tooltips? This way a wider audience will see the site the way you intended.

Share this post


Link to post
Share on other sites

At last I found someone who thinks like me... That's why they are in there in the first place, for the benefit of the Older Browsers... but with the trend towards using strict Doc Types and validations, etc, I thought it might be time to drop them from the code. Not yet, eh?

Share this post


Link to post
Share on other sites

Leave the alts where they are for people who browse with images turned off. It doesn't hurt from an SEO point of view either cos it gives you another opportunity to use keywords.

Share this post


Link to post
Share on other sites

PHP paging script updated. Test it here.
New version of the Zip file here.

Changelog: Added a security check to ward off injections by using the htmlentities() in the GET['page'].

Let me know if this fails for you... or if you are able to add injections. :lol:

Share this post


Link to post
Share on other sites

Wow, it's great!I really need a templating system for my projects but I want to make it like... forums use it... You know...But this is still good, very good!Nice work.Though, why it echoes $_GET['page']; ? :lol:

Share this post


Link to post
Share on other sites

Where? in the title tag? that changes the information in the tab label to describe which page you are viewing.

<title>Template :  <?php echo 'Page: '  . $_GET

; ?></title>

Share this post


Link to post
Share on other sites

no ,no!
in Array script

$submit = $_GET

;echo  $_GET

;
:lol:

Share this post


Link to post
Share on other sites

I think that was a test echo used while I was developing the script. It might be required to space the contents down the page in the HTML so the fixed header doesn't cover the top of the contents. Can't remember exactly.

Share this post


Link to post
Share on other sites

Ever wonder how to make your site one file? For example, in these forums, the posting page is index.php?act=post and so on. This tutorial will teach you how to do that. First, you'll need a text editor, and a PHP supported server. You can achieve this type of navigation by using the example below:

<?php$action = $_GET['action'];  //Gets whatever action equals from the url.  Example:  index.php?action=news  Since action equals news, it will display whatever is in the "news" if statement.echo "<a href='index.php'>Main</a> | <a href='index.php?action=news'>News</a> | <a href='index.php?action=other'>Other</a>";  // This navigation will appear at the top of every page.if($action == ""){  //If the url is just index.php, then action is blank.  Let's echo some text.   echo "Content of the main index page.";}if($action == "news"){  //If the action equals news, then echo some more text.   echo "This is the news page of the site.";}if($action == "other"){  //If the action equals other, then echo some different text.   echo "This is some other page.";}?>

You can also use includes to shorten your coding. After all the code is together, it can get kind of long and confusing. For example, you could use this:

if($action == "news"){

include('news.php'); //Includes a file called news.php

}

?>

 

And there you have it. A very simple script that you can use to make your website more organized and have less files. You don't have to do your whole site with the index page. For example, if you run a hosting site and you want the hosting plans to be hosting.php but you don't want a seperate page to apply, you can use hosting.php?action=apply.

 

Hope this tutorial helped you guys.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.