template code stored in DB vs in files

Do not post support requests, bug reports or feature requests. Discuss phpBB here. Non-phpBB related discussion goes in General Discussion!
Suggested Hosts
Post Reply
asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

template code stored in DB vs in files

Post by asinshesq » Tue Apr 03, 2007 10:49 pm

I see that the html code for the prosilver templates appears in files in the styles/prosilver/templates folder and separately appears in the phpbb_styles_template_data table in the db.

I gather that the reason for the duplication is so that when an admin edits a template in the ACP, if the server is set up to disallow writing, the changes can be stored in the db. Is that correct?

I assume that phpbb3 figures out whether the copy in the db is more recent than the file copy in the folder and only uses the db copy if it is more recent, correct?

Does it slow up the site noticeably to be using db templates rather than file templates? Is that something an admin should try to avoid? And once the admin makes a change in the db version, is there a way to get phpbb3 to start recognizing the file version again? Is that as simple as re-saving the file version?

User avatar
Highway of Life
Former Team Member
Posts: 6048
Joined: Wed Feb 02, 2005 5:41 pm
Location: Seattle, WA
Name: David Lewis
Contact:

Re: template code stored in DB vs in files

Post by Highway of Life » Wed Apr 04, 2007 2:41 am

asinshesq wrote: I see that the html code for the prosilver templates appears in files in the styles/prosilver/templates folder and separately appears in the phpbb_styles_template_data table in the db.

I gather that the reason for the duplication is so that when an admin edits a template in the ACP, if the server is set up to disallow writing, the changes can be stored in the db. Is that correct?
Correct.
asinshesq wrote: Does it slow up the site noticeably to be using db templates rather than file templates? Is that something an admin should try to avoid? And once the admin makes a change in the db version, is there a way to get phpbb3 to start recognizing the file version again? Is that as simple as re-saving the file version?
The difference all depends on the speed of your Database Server to the Apache server, sometimes it can be just as fast, sometimes a bit slower.
Everything will end up cached, however, so it ends up being about the same speed.
You can switch the templates from database to file system and back again at any time. But once you make another change, it will switch back to DB.
You may not retain any changes you made to the templates in the DB if your server does not allow phpBB to write back to the template files.
You can also choose to "export" your style, which saves the most recent version of all of the templates (including DB and files).
Which you can use to replace the files you have to be sure you have the most updated version.
The phpBB Weekly Podcast - Discussing the developments of phpBB4 and beyond.

New to phpBB3? Want to learn about programing?
Visit phpBB Academy at StarTrekGuide to learn how.

asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Re: template code stored in DB vs in files

Post by asinshesq » Wed Apr 04, 2007 12:06 pm

Thanks, Highway.
Highway of Life wrote: You can switch the templates from database to file system and back again at any time. But once you make another change, it will switch back to DB.

How do you switch back from database to file system? Is it just a question of resaving one of the template files? Will that only switch back for that particular template or will that switch back for all of them?

Az
Registered User
Posts: 204
Joined: Sat Oct 25, 2003 9:38 pm
Location: SE England
Contact:

Re: template code stored in DB vs in files

Post by Az » Wed Apr 04, 2007 1:55 pm

asinshesq wrote: How do you switch back from database to file system? Is it just a question of resaving one of the template files? Will that only switch back for that particular template or will that switch back for all of them?


If you just want to swap how it's stored, go to the ACP, then Styles -> Templates -> Details. It lets you choose there on a per style basis as to how you want it stored.

User avatar
ChrisRLG
Former Team Member
Posts: 3420
Joined: Wed Nov 24, 2004 3:18 pm
Location: Essex, UK
Contact:

Re: template code stored in DB vs in files

Post by ChrisRLG » Wed Apr 04, 2007 2:39 pm

what settings would be required on the server to allow it to run from the files - 666 ?
phpBB: The All Important Rules - Bertie Bear 3.0 - No support via PM system - use the forums please.
phpBB v2: Retirement (1/1/2009) : phpBB v3: Read Me Topic - Custom BBCodes - Support Template
Matthew 7:7"Ask and it will be given to you; seek and you will find; knock and a door will be opened to you."
My Links: MS MVP (Consumer Security) - Malware Removal:University - Own Forum: Custom BBCode testing

Az
Registered User
Posts: 204
Joined: Sat Oct 25, 2003 9:38 pm
Location: SE England
Contact:

Re: template code stored in DB vs in files

Post by Az » Wed Apr 04, 2007 4:45 pm

ChrisRLG wrote: what settings would be required on the server to allow it to run from the files - 666 ?


I'm not entirely sure, but I imagine setting 755 as the permissions for the template files would allow it to work.
IIRC, setting at 666 wouldn't allow them to be executed properly.
Edit: Obviously that's only if you edit the files from the ACP, otherwise it just runs from the template files anyway.

Post Reply

Return to “phpBB Discussion”