![]() |
serve template from filesystem instead of DB
Hi,
I'm trying to serve the template from filesystem instead of DB so I followed this short tut here: http://www.vbulletin.com/forum/forum...to-file-system there is another tut has been around for a while, but it doesn't work anymore since vb has made a lot of updates and changes: http://www.go4expert.com/articles/ex...-files-t25345/ what I did is the following: 1- created a folder in the root named template_dump with CHmod 0777 2- turned on your debug mode $config['Misc']['debug'] = true; 3- created the files visiting this url on my forum: http://FORUM_NAME.com/admincp/template.php?do=createfiles&dostyleid=your_active_ style 4- moved the folder template_dump to under includes ( includes/vb_templates ) 5- in includes/class_core.php --> replaced protected static function fetch_template($template_name) with can protected static function file_get_contents (DIR. '/includes/vb_templates/'.$template_name.'htm') after all that my forum doesn't work... sounds like there is something wrong... any idea what's going on? :confused: Thanks Update: I made a mistake posting in vb3 section where this actually supposed to be on vb4 |
Did you do your active style and -1 for the master style? Otherwise you will only get templates that are different from the master style.
Not to mention you can't just replace the function with "file_get_contents" - now you have a function named "file_get_contents". I would play around with the fetch_template_start hook and try putting in the code from the second page: PHP Code:
Then create the child style '<<< FILE >>>' |
I would restore your file includes/class_core.php back to original and create this plugin for fetch_template_start:
Code:
Now try playing around with commenting out the database query and replacing it with file_get_contents(). You should actually open, lock, read and unlock the file instead of just reading it with f_g_c() |
Quote:
I'm somehow new to this so not sure what database query I should be replacing with file_get_contents() can you give an example? --------------- Added [DATE]1411452481[/DATE] at [TIME]1411452481[/TIME] --------------- Quote:
Thanks mate for the quick solution. I have done the steps as you instructed me. now only thing is how do I know it is working or not?? how do I test it? |
Quote:
Edit: I think tpearl's code would work because the code in fetch_template() gets it from the cache if it's set. |
Quote:
not sure of another way on how to test it though. any idea?? :( |
yep, setting debug mode should tell you where the templates are being read from in the bottom dropdown...
--------------- Added [DATE]1411485646[/DATE] at [TIME]1411485646[/TIME] --------------- Quote:
fyi, vb optimise has a feature to do all of this and/or read templates from the cache of your choice. |
Quote:
|
Quote:
Code:
if (!$fetched) echo 'test hook<br>'; and got many echos of test hook |
Well yeah, "return" ends the plugin execution, but what I was saying is that it doesn't end the execution of fetch_template(), so if your plugin code doesn't set $fetched to true or set $vbulletin->templatecache["$template_name"], then fetch_template will go on and do it's work. And even if the plugin does one of those things, I don't think you'd want to increment the usage count since that will happen in any case.
Edit: I think I misunderstood the above post - what I was saying is if you were to for instance create a plugin that just contained a return, that wouldn't stop the rest of fetch_template from running. It's not exactly the same as insertng the code at the point the hook is eval'd. Also if the hook is called inside a loop you can't break or continue that loop from the plugin. Maybe you knew all that and you assumed the code would be changed to remove that stuff, but I thought it could be clarified. Or maybe I'm missing something. |
All times are GMT. The time now is 06:41 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|