The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
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? Thanks Update: I made a mistake posting in vb3 section where this actually supposed to be on vb4 |
#2
|
||||
|
||||
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 >>>' |
2 благодарности(ей) от: | ||
fxdigi-cash, ozzy47 |
#3
|
|||
|
|||
I would restore your file includes/class_core.php back to original and create this plugin for fetch_template_start:
Code:
if (!$fetched) { if (isset($vbulletin->templatecache["$template_name"])) { $template = $vbulletin->templatecache["$template_name"]; } else { self::$template_queries[$template_name] = true; $fetch_tid = intval($templateassoc["$template_name"]); if (!$fetch_tid) { $gettemp = array('template' => ''); } else { $gettemp = $vbulletin->db->query_first_slave(" SELECT template FROM " . TABLE_PREFIX . "template WHERE templateid = $fetch_tid "); } $template = $gettemp['template']; $vbulletin->templatecache["$template_name"] = $template; } } if (!isset(self::$template_usage[$template_name])) { self::$template_usage[$template_name] = 1; } else { self::$template_usage[$template_name]++; } /////////($hook = vBulletinHook::fetch_hook('fetch_template_complete')) ? eval($hook) : false; return $template; 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() |
3 благодарности(ей) от: | ||
fxdigi-cash, Max Taxable, ozzy47 |
#4
|
|||
|
|||
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? |
#5
|
|||
|
|||
Quote:
Edit: I think tpearl's code would work because the code in fetch_template() gets it from the cache if it's set. |
Благодарность от: | ||
fxdigi-cash |
#6
|
|||
|
|||
Quote:
not sure of another way on how to test it though. any idea?? |
#7
|
||||
|
||||
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. |
#8
|
||||
|
||||
That's exactly what I use, and do.... And had forgotten about it!
|
#9
|
|||
|
|||
Quote:
Code:
if (!$fetched) { if (isset($vbulletin->templatecache["$template_name"])) { $template = $vbulletin->templatecache["$template_name"]; } else { self::$template_queries[$template_name] = true; $fetch_tid = intval($templateassoc["$template_name"]); if (!$fetch_tid) { $gettemp = array('template' => ''); } else { $gettemp = $vbulletin->db->query_first_slave(" SELECT template FROM " . TABLE_PREFIX . "template WHERE templateid = $fetch_tid "); } $template = $gettemp['template']; $vbulletin->templatecache["$template_name"] = $template; } } if (!isset(self::$template_usage[$template_name])) { self::$template_usage[$template_name] = 1; } else { self::$template_usage[$template_name]++; } ($hook = vBulletinHook::fetch_hook('fetch_template_complete')) ? eval($hook) : false; echo 'before return<br>'; return $template; echo 'after return'; echo 'test hook<br>'; and got many echos of test hook |
#10
|
|||
|
|||
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. |
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|