The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Replace variable in template
Hello.
I am currently trying to make myself a simple template engine, for the sake of learning. I have a table i my db with the following tables: Code:
t_id, t_name, t_content PHP Code:
PHP Code:
PHP Code:
Is there a good way to do this? I cant for the world understand how this would work. Im hoping for some sort of automated script which replaces the right stuff in the right template, calling the right tables etc. just by printing a function with some values or something. Any help would be greatly appreciated! Thanks in advance Niklas |
#2
|
||||
|
||||
I wrote a mini-template class a while back. I modified it a bit for your needs. Give it a try if you want.
PHP Code:
PHP Code:
|
#3
|
|||
|
|||
Just what I was looking for, finally I understand!!
Thank you so much for helping!! =) |
#4
|
||||
|
||||
No problem. If you still have questions on this, just ask.
|
#5
|
|||
|
|||
Ok I actually have one more question.
Your script works perfect, but there's something I dont really know. I have a a tempalte aclled "index". In the index template theres a variable called "$news". The $news veriable should be replace with a tempalte called "news". That template looks something like this: HTML Code:
<blockquote class="go"> <p> <h3>$title</h3> - <h5>posted: $date</h5> </p> <p> $content </p> </blockquote> Thank yuo so much for taking the time! Niklas |
#6
|
||||
|
||||
Well it's just a simple template system. There's no real good way to do it. One of them would be something like this.
PHP Code:
Assuming the fields in the database are called "news", "date", and "content". Otherwise try this PHP Code:
|
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|