Announcement

Collapse
No announcement yet.

Database-driven templates

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Anakin
    replied
    Yup, that all pretty much makes sense actually. I was wondering why eval was used but you explained that.

    If my system is a tenth as good as that in vBulletin, I'll be very happy indeed

    PS So long as you don't mind, I'll "borrow" that quote from your signature too (I'll use it on my forums)

    Leave a comment:


  • Chen
    replied
    Here's a small tip. If you still need help, contact me via ICQ or through vB.org's IRC channel and I'll try to help more.

    If you take this eval() call, for example:
    PHP Code:
    eval('$variable = "'.gettemplate('template').'";'); 
    And we'll assume template contains "My name is $name", and $name contains the string 'Chen'.

    The code that is being executed by eval() would be:
    Code:
    $variable = "My name is $name";
    So $name is replaced with Chen, and $variable ends up being "My name is Chen".

    This way you use $variables for variable things (*shock*), and when you eval() the template those $variables are replaced with the real thing.

    Hope this helps.

    Leave a comment:


  • Anakin
    started a topic Database-driven templates

    Database-driven templates

    Having spent many many hours looking through the vBulletin templates and code I'm about to develop a database-driven template system like that used in vBulletin, for the next version of my site.

    However I'm having difficulties. Does anyone know of any good articles on this subject?

    The thing I am finding particularly confusing is that the vB developers used code like "eval("\$welcometext = \"".gettemplate('forumhome_welcometext')."\";");" in order to get a template from the database. However I don't understand how any PHP code in this database is actually executed, and even why the "eval" function is used.

    Can anyone shed any light on this?

    Thanks

Related Topics

Collapse

Working...
X