The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Performance: preg_replace or hardcoded?
Hi all,
I have plugins which adds some data to forumbits etc by using $thread[] array and hardcoded html with something like {vb:raw thread.mydata}. Which approach is the better from the position of performance: to parse template_compile and use e.g. preg_replace, or just hardcoded piece of html into existent template? |
#2
|
||||
|
||||
I recommend using preg_replace only if:
- the amount of text is "not too much" in one request - the data may change often - the replacement is context-sensitive, which means a normal str_replace is not sufficient - the data needs to be fresh (non-cached) It would be helpful to get a more specific example on what you actually want to do. |
#3
|
|||
|
|||
Example: add data after
Code:
<li id="forum1" class="forumbit_post L2"> First variant: get needed data $thread[‘mydata’] and use str_replace in template_compile hook to append it after <li Second variant: add html to forumhome_forumbit_level2_post template. Code:
<li id="forum1" class="forumbit_post L2">{vb:raw thread.mydata} So, from the position of performance which variant is better? |
#4
|
||||
|
||||
In any case it's better to use second way with the template system, because templates get cached. So this text gets generated once every few minutes, depending on the cache lifetime and can be viewed by hundrets of users.
The first method would replace a small text into a huge text for every site request, thus increasing the server load unnecessarily. Also, it's more clean to use the templates as they are intended. |
Благодарность от: | ||
Maccrob |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|