You are invited to Log in or Register a free Frihost Account!

PHP as site template?

So I am looking into creating not just A web-page but a web-site where there is a common theme. This theme I want and will create from scratch. However, I am lost on the best practices of this?

I have given some thought and have come up with a few ideas:

1) Create seperate PHP files (ie: header.php, footer.php, side_bar.php, etc);
Then main page of each link I will use the include code to insert these into each page
I will use CSS to format the pages

2) Use DIV's and CSS to format and position the header/footer. Maybe use a php page and use echo's for the CSS link and use include for the PHP pages???

3) Perhaps use MySQL with a table called Default_Layout with a row for each element for CSS and a field for all of the values? (IE: a {color:red; text-decoration:none} would be one row with two fields?

Now that I think about it again, I think the third example will work best.

Any ideas?

why use MySQL for templating?!?
Well because a have a friend that makes web-sites on the side and he used SQL to do so, I believe. He has a few master pages that are layed out a specific way, and you choose which layout you want and then start filling in content in the different areas of the page. Each area is named, and you just use a drop down box to determine the content and another to determine the area.

He also has another master page that allows him to create a page. On this master page he chooses the color and font and other vaious elements and their values. This to me, seems like a very useful way of creating web-pages since you will have a master page and you choose the contents via drop-down menu.

Does this make more sense?

I think the MySQL is an interesting way of doing it - albeit complicated. I think it would only work in certain circumstances and where you want somebody with little or no html knowledge to be able to update the header/footer through a form.

Personally, I use central header and footer php files and just include them on each and every page.

You don't need a seperate file for the sidebar. I have my sidebar included in my footer.

3) Perhaps use MySQL with a table called Default_Layout with a row for each element for CSS and a field for all of the values? (IE: a {color:red; text-decoration:none} would be one row with two fields?

Like Richard said, why don't you just include them? You can do this on each page by putting this in the code:

<link rel='stylesheet' href='URLTOMAINCSS.CSS' type='text/css' />

Then just set the style names in each page. That would be much easier than using MySQL to store all of the information in a database.
And you can include actual files by using

<?php include("filename"); ?>

Let me know if you need any help.
adeydas wrote:
why use MySQL for templating?!?

Only way I see this useful is if it's per-user so people can customize how they view your site. Probably too complex and not useful enough to bother. Could also help if you really want to be able to change the way it looks through an admin menu type thing, but again, may be too complex just for that.

You may want to look into smarty but using a header and footer is probably good enough.
If you want multiple themes for different pages why not just use some php var for each theme and depending on the var load the right css file?
You could get the var from cookies or set the var in the page so users won't be able to change it, also sessions and a default theme easy to do this way.
minty wrote:
So I am looking into creating not just A web-page but a web-site where there is a common theme....

Well, why not use a simple templating engine? I don't know, but it seems to me that using a template engine will save you a lot of work. I usually use bTemplate, but there' are other big ones like Smarty...
PHP is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML. If you are new to PHP and want to get some idea of how it works, try the introductory tutorial. After that, check out the online manual, and the example archive sites and some of the other resources available in the links section.

SO use it as it was made for?
OK looks like CSS, PHP, JS are going to be the way to go for a complete site template.

However, I guess I did not ask the question the way I needed to to get the answer I am looking for. I was wanting to use PHP/MySQL to create pages on my site with the configuration that I explained before. Does this help in realizing in what I am looking to do?

By this I mean instead of using Notepad or some other text editer to write the scripts or even using a WYSIWYG program, I am looking to create a web-page that will be used to create other pages.

So as I stated above I will have a master page (the template) with defined areas and other scripts (calendars, headers, footers, etc) that I create. I will then use this master page to assign the scripts (or pages) to different parts of the template creating a customized page from the template.

Do think that using PHP/MySQL would work for this or is this just working too hard and I can use a program that has already been created to do this for me??

Thanks again for all of your responses!!

If that's what you want your site to do, then I would go with the third option. I warn you, even though I could do it, I think it's a loooong work if you want to do it right (it's long, not that difficult).

Have you used any boards like InvisionFree? I remember 4 years ago when I used them for a small experiment (wanted to know if a exploit worked), I analysed the admin panel... and then I checked on some other pre-made systems, like CMS's and Forums. I have never seen the code they use for their admin panels, but I bet you could find it useful.

I say you go with the third option, because I already worked with a professor, back when I was in highschool, in which we used MySQL for the site's configuration. It was much more complex than using the options other's have mentioned, but it was very useful for what he was asked to do (they needed a very configurable system).

So... go ahead, but you will have to dedicate a lot of time.

Im clueless on this PHP thing, where is a good place to start using it and learning how to actually use the stuff?

If anyone has any good ideas please just let me know what you can,

Related topics
Phoenix free PHP scripts
Site Template
Should I make a flash site?
Working with Excel, PHP & MySQL. Any Ideas
Web Site Template Paying over 100 Frih$ (Closed)
php coding needed
PHP Web Templates
looking for a games ssite template
links dont work in IE from frihost hosted site
e107 php???
Site Template FRIH$ available
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

© 2005-2011 Frihost, forums powered by phpBB.