Jump to content
xisto Community
alex198555

Templates? How to make it?

Recommended Posts

Hey, guys. I am building my own PHP Content Management System. There is a question for all of you. How can I make templates and apply it to my web-site. For instance, I want that borders, colors or the location will be changed when the template is applied. I want that it can be done by a user and admin can do it as well for admin center, let's say. If you have a link to a nice tutorial, please post.

Share this post


Link to post
Share on other sites

Hey, guys. I am building my own PHP Content Management System. There is a question for all of you. How can I make templates and apply it to my web-site. For instance, I want that borders, colors or the location will be changed when the template is applied. I want that it can be done by a user and admin can do it as well for admin center, let's say. If you have a link to a nice tutorial, please post.

a template in php can easily be structured by html code. The other things that will fit in can be taken from the variable which you specify so its very easy, for example:

 

-you can have an html page with the following:

<html>Your name is: <?php echo $username; ?><br />And you live in: <?php echo $location; ?></html>

Thats the easiest i could come up with...as you can see its very basic and the idea is that the user's info will change depending with his/her information.

 

for want you want to happen, to change borders and everything, its a small matter of doing something similar to:

<table border="<?php if($layout == 'yellow') echo 1px yellow solid ?>">

of course that depends with your structure and how you want to switch between the values. I hope you got the logic, if you had more info i'd be happy to help.

 

Cheers


Share this post


Link to post
Share on other sites

Do some research on model view controller (MVC). Many, if not most, template systems run off of this principle. Much of the content that the template will contain when sent to the browser will always be the same no matter which template is used. Therefore the template system requires access to functions or keywords that retrieves data for to be inserted in their appropriate places.

Share this post


Link to post
Share on other sites

Adding on to what is said, you should add an INFO file or something for each template and store certain variables in a database.Of course in more sophisticated CMSes Pure HTML isn't used but generated GIF/PNG border images.

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

×
×
  • 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.