Template System


I have a row called “template” in my database which is filled with HTML code.
Let’s say it looks something like this:

  <div class="profile">{profile->USERNAME}</div>

{profile->USERNAME} Is supposed to change to let’s say “Admin”, since it’s a template system it works if you use a simple HTML file. Although I want to go a bit further.
The {profile->USERNAME} does not return anything it just looks the same.

There’s not enough information in this question to help you. Put yourself in the shoes of the random programmer you’ve just asked for help. Would you be able to propose a solution knowing only what you wrote? Try to think of the several questions he’d ask you before he can even think about how to help.

This is unusual to have a object style code in the template
Normally you would just have {USERNAME} placeholder and then the templating system will replace it with some username

There are many templating systems for php, you just have to pick one and learn how to use it. I don’t see any reasons to develop your own templating system, simply because there are so many of them out there.

Well, I’m sorry about that… I was pretty tired when I wrote it.

I have a template system, each user is should be able to change their own HTML file(template).
Instead of having a folder and files for every user I thought it would be easier if it went through a database table.
Table name: Templates
Rows: userID, template & stylesheet.
The template row contains HTML code that could look like this:


Of course the code doesn’t look like that but, it has it’s similarities.
The template and stylesheet row is fetched through a SQL query in a PHP file.
They both are fetched and working except that the {TITLE} and {profile->USERNAME} stays the same. It works if you forget about the templates table and connect through just a HTML file.

Hope that sums it all up.

What code drives the template?
Something has to go in and replace the {TITLE} and {profile->USERNAME} with some other values.

More verbal description doesn’t help – we need to see the code that drives the template system to advise you how to modify it to use a database instead of files.