Author Topic: Templates from DB ?!?!?  (Read 3531 times)

0 Members and 1 Guest are viewing this topic.

zyBRA

  • Guest
Templates from DB ?!?!?
on: Tue, 17. December 2002 - 17:27:07
Hi!

Is it possible to parse templates directly from db ???


Regards,

zyBRA

releasedj

  • Guest
Templates from DB ?!?!?
Reply #1 on: Tue, 17. December 2002 - 19:43:14
It's currently only possible to access templates from a filesystem.

This is, however functionality which will be considered in the very very near future.


Regards,

Kelvin

Offline ClausVB

  • Administrator
  • Hero Member
  • *****
  • Posts: 566
    • Homepage: clausvb.de
Templates from DB ?!?!?
Reply #2 on: Tue, 17. December 2002 - 20:32:17
Two things in this matter:

1. People I talked to say: "The filesystem is faster than DB."

2. I expirienced problems with phpMyAdmin exports regarding large templates. It could not reimport them.

I would not change that, but that's only my opinion.

Regards,
Claus

zyBRA

  • Guest
Templates from DB ?!?!?
Reply #3 on: Tue, 17. December 2002 - 21:07:49
Ok, I believe that is a very interesting and useful 'additional feature' assuming that user can have a text table row with vlibtemplate tags in it, thus the engine fetch(parse) this text that can be included in another template for example or be used(once parsed) with a common setVar ... Maybe somebody agree!

RNilsson

  • Guest
Templates from DB ?!?!?
Reply #4 on: Tue, 17. December 2002 - 21:47:49
Perhaps a config-variable that defaults to filesystem-templates? But have the ability to store them in db...

That way you can make your templates in the filesystem, and once they really do work, you perhaps can choose to import them into the db and switch over to the db-templates.

Or perhaps even two different sets of functions/classes...one that work with filesystem-templates (like the current one) and another class that uses db-templates.

Anyways, just rambling on...

Offline ClausVB

  • Administrator
  • Hero Member
  • *****
  • Posts: 566
    • Homepage: clausvb.de
Templates from DB ?!?!?
Reply #5 on: Tue, 17. December 2002 - 21:49:39
I read your post three times.

I am afraid, I do not understand it.

You want to put
{tmpl_var name='XY'}
into a table (TEXT).

What would be the benefit of that?

Perhaps it is obvious to everybody else, but I miss the point.

Sorry.

*I hope you will explain it to me.*

Regards,
Claus

zyBRA

  • Guest
Templates from DB ?!?!?
Reply #6 on: Tue, 17. December 2002 - 22:19:14
Quote
You want to put�
{tmpl_var name=XY}�
into a table (TEXT).�

What would be the benefit of that?
Assume Ive a user level that not have access to the template file, but i give it some vlibtemplate tags that it can use on a form to store in db, for example, {tmpl_var name="date_now"}, {tmpl_var name="section_title"}, etc ...

Sorry 4 my poor english, hope you understand me now...
Last Edit: Wed, 19. October 2005 - 22:44:33 by ClausVB

releasedj

  • Guest
Templates from DB ?!?!?
Reply #7 on: Wed, 18. December 2002 - 11:15:56
The example you gave isn't really an issue with vlibTemplate. What you decide to do with the variable you get from a form submission is up to you. vlibTemplate will never handle this.

As for getting the templates from a DB, I think that it's a fair suggestion, and it would be good to get any comments on how people would envisage this implementation.


Regards,

Kelvin

zyBRA

  • Guest
Templates from DB ?!?!?
Reply #8 on: Wed, 18. December 2002 - 16:04:06
Hum ... I never said that vlibtemplate should handle a form submission, it's only a example ... vlibtemplate should handle only the db where the user have stored the text with vlibtemplate tags ...  :roll:

releasedj

  • Guest
Templates from DB ?!?!?
Reply #9 on: Wed, 18. December 2002 - 16:30:42
Sorry, that's what I thought you meant the first time, then I got a little confused with your last post.

I'll definately be looking into adding this functionality to vlibTemplate, but I can't make any promises as to when it will be.

Regards,

Kelvin

PS: It's probably best to refer to the text with vlibTemplate tags in it as a template, whether it's on the file system or not doesn't matter, that there's no confusion.

RNilsson

  • Guest
Templates from DB ?!?!?
Reply #10 on: Wed, 18. December 2002 - 16:32:57
I don't know if it was my post that was a garble, but if you have a table in the db that looks like this (only an example):

vlibTemplates[tmplID][tmplName][tmplContent]

with this content:
tmplID = 1
tmplName = Header
tmplContent = <some htmlcode, vlibTemplate tags etc>

tmplID = 2
tmplName = News
tmplContent = <some htmlcode, vlibTemplate tags etc>

and instead of calling the file fron the filesystem like this:
$tmpl_header = new vlibTemplate('./templates/header.html');
$tmpl_newsheader = new vlibTemplate('./templates/news.html');

you could call them like this:
$tmpl_header = new vlibTemplateDB($ID = '1');
$tmpl_newsheader = new vlibTemplateDB($ID = '2');

OR with name:
$tmpl_header = new vlibTemplateDB($NAME = 'Header');
$tmpl_newsheader = new vlibTemplateDB($NAME = 'News');

And you can still use the same syntax as when using the db as filesystem.
And that you can let vlibTemplateCache re-generate with the templates from the db if you wish.

Just spilling my thoughts here, i'm unfortunately not so good at describing in text...

But, i know that VBB (vBulletin Board) use db-stored templates for it's styling.

zyBRA

  • Guest
Templates from DB ?!?!?
Reply #11 on: Wed, 18. December 2002 - 18:05:26
Exactly!!!  :D

And more ... you could store the parsed template into a variable and use it in a setVar function, for example:

$news = 'parsed template from db';

$tpl->setVar('News', $news);

releasedj

  • Guest
Templates from DB ?!?!?
Reply #12 on: Wed, 18. December 2002 - 18:46:35
I think it would be easier to do:

Code: [Select]
tmpl_dbinclude ...
Then you could stick to syntax that youre used to.
Im still thinking the whole thing through, and when I have more of an idea of exactly how it can be done, Ill post something to this forum.

Regards,
Kelvin
Last Edit: Wed, 19. October 2005 - 22:47:27 by ClausVB

Offline ClausVB

  • Administrator
  • Hero Member
  • *****
  • Posts: 566
    • Homepage: clausvb.de
Templates from DB ?!?!?
Reply #13 on: Wed, 18. December 2002 - 23:55:53
I know some BB (like vBB) use DB-templates, but did anybody made performance test's on that?

All people I know, who did it said it was slower, so I do not care if it's easier to program that way. If my site crashes because 2000 users try to access it at the same time, it would have no use for me.

I hope it will stay an optional feature.

Regards,
Claus

releasedj

  • Guest
Templates from DB ?!?!?
Reply #14 on: Thu, 19. December 2002 - 12:00:42
Of course it will be optional, I'm not going to suddenly force people to use a Database to store their templates, that would be crazy.

It could perhaps give you the chance to store templates in a Database, but cache them to the filesystem for general access, that way you wouldn't access the database every time, however you would have the advantages of being able to edit them easier using phpMyAdmin for example using a web based interface.

Regards,

Kelvin

Offline ClausVB

  • Administrator
  • Hero Member
  • *****
  • Posts: 566
    • Homepage: clausvb.de
Templates from DB ?!?!?
Reply #15 on: Thu, 19. December 2002 - 15:22:46
That it will stay an optional feature is a good idea.

And to cache the templates is brilliant, so it will not be as slow as I thought. Perhaps it is not slower at all.

But imho the whole feature is not necesarry to please one, two or five users. If 10 or 20 would ask for it I would do it.

It totally Kelvin's decision, because he has to figure it out, to program it. All I want to say: What is the benefit?

- phpMyAdmin => every german provider I know offers a feature to access files directly. I think there are PHP scripts which offer that feature.
- @zyBRA: Quote releasedj: "The example you gave isn't really an issue with vlibTemplate" I agree. What you told us sounds a little bit like a CMS problem. "No access to the template, but to some tmpl-tags."

Perhaps I am too stupid to understand this, but in my humble opinion this feature is not worth programming it.

I always had problems with templates stored in a DB. Not to mention people who have only a 5 MB MySQL database. 250k templates and a large user forum could mean: 5000 posts less capacity. I never tried GZIP compression, though.

I have to admit, that I understand, why some boards are using it: If you have more than 250 templates (like wbb="woltlab burning board"), which are about 350 bytes it takes forever to copy them via ftp.

But imho the wbb tmpl structure is not very fortunate.

But I leave this decision to Kelvin.

Regards,
Claus

releasedj

  • Guest
Templates from DB ?!?!?
Reply #16 on: Thu, 19. December 2002 - 17:37:18
You could say that the 3-step-loop was created for 1 or 2 people wanting it. As it turns out, it's very easy to use, easier than the setLoop() function.

What I mean to say is that, I think it's a good idea, and I'll be happy to code it when I have the time.. it will at least give people the option of storing templates in a different way.

Regards,

Kelvin

RNilsson

  • Guest
Templates from DB ?!?!?
Reply #17 on: Thu, 19. December 2002 - 21:22:43
RE: FS vs DB performance...

I don't know which one is faster, but i can imagine that 2000 hits is to put a huge strain on the cpu, io and filesystem as webb.

And if it's "only" about speed, then you would need the webhost to run zend and some cache-accelerator like phpa or apc or something similar.

But, i'm almost convinced since almost every "modern" site get's it stuff from the db anyways, you already have the connection to it, and you just make one, or perhaps two extra db-quyries.

Take phpBB2 for instance, i believe that each "thread" page is around 10-15 quyries (not sure here tho).

But, i'm not an expert or anything, i just think it'd be nice to have each "different"  template-theme in it's own table, or with it's 'themeID' or something similar.

Then you can actually have some php-frontend that you use to maintain these templates *just cool feature tho =)

Offline ClausVB

  • Administrator
  • Hero Member
  • *****
  • Posts: 566
    • Homepage: clausvb.de
Templates from DB ?!?!?
Reply #18 on: Sat, 11. January 2003 - 01:25:04
Quote
Take phpBB2 for instance, i believe that each "thread" page is around 10-15 quyries (not sure here tho).
phpBB does not use templates stored in the database. I checked the latest release.

Quote
Then you can actually have some php-frontend that you use to maintain these templates *just cool feature tho =)
Are you aware there are PHP scritps that help you editing your files on your webserver?

Imho phpMyAdmin is the worst editor for templates in the world. Surprise, surprise ... its not meant to be.

I say: Templates in the DB or as file does not matter for maintaining. Imho its easier to change a file via editor, web-interface or whatever.

I only see two advantages for DB-template system:
1. No problems with CHMOD and so on.
2. You have all your data at one location.

But large templates are not that easily exported. I know that, because I tried it using XMB. They store the templates in the database.

Sorry, I still do not see the point of it.

Regards,
Claus
Last Edit: Wed, 19. October 2005 - 22:50:43 by ClausVB

nomic

  • Guest
Templates from DB ?!?!?
Reply #19 on: Wed, 26. March 2003 - 16:12:37
Quote
You want to put
{tmpl_var name=XY}
into a table (TEXT).
What would be the benefit of that?
I did something like this for my program, too. Its an internationalization feature.
Last Edit: Wed, 19. October 2005 - 22:52:55 by ClausVB