phpBB2Refugees.com Logo
Not affiliated with or endorsed by the phpBB Group

Register •  Login 

Continue the legacy...

Welcome to all phpBB2 Refugees!Wave Smilie

This site is intended to continue support for the legacy 2.x line of the phpBB2 bulletin board package. If you are a fan of phpBB2, please, by all means register, post, and help us out by offering your suggestions. We are primarily a community and support network. Our secondary goal is to provide a phpBB2 MOD Author and Styles area.

template.php to statically write language vars to cache


 
Search this topic... | Search MOD Requests... | Search Box
Register or Login to Post    Index » MOD Requests  Previous TopicPrint TopicNext Topic
Author Message
qspy
Board Member



Joined: 03 Nov 2009

Posts: 10



PostPosted: Thu Nov 05, 2009 5:52 am 
Post subject: template.php to statically write language vars to cache

This is theory, not checked it deeply, but i think main_lang.php is scanned a lot to retrieve lang['text'] even from cached template files.

If it is indeed scanned like this, it can cost a lot of php processing time at heavy load especially.

Am i right? Someone made this before? i am missed something?

example cache/tpl_name.index_body.php
Code:
<th width="50" class="thTop" nowrap="nowrap">| <?php echo isset($this->vars['L_TOPICS']) ? $this->vars['L_TOPICS'] : $this->lang('L_TOPICS'); ?>| </th>

(btw, stupid code wtf icon_surprised.gif, if a = 1 then a = 1 else a = 1)

could be made static:
Code:
<th width="50" class="thTop" nowrap="nowrap">| Topics | </th>
Back to top
Acaria
Board Member



Joined: 20 Feb 2009

Posts: 238



PostPosted: Thu Nov 05, 2009 6:44 am 
Post subject: Re: template.php to statically write language vars to cache

I don't think it works that way. I think it's set up so all lang variables can be called from anywhere, like an include hidden somewhere around the code.

Not sure though. Wait for someone like Dog Cow to come in and explain it perfectly in one sentence. XD
Back to top
Ptirhiik
Board Member



Joined: 19 Nov 2008

Posts: 114


flag
PostPosted: Thu Nov 05, 2009 7:38 am 
Post subject: Re: template.php to statically write language vars to cache

Using lang files versus static text serves two purpose : using the same text everywhere for the same object, and allowing the interface to be translated in many languages. It costs more resources (uc/memory) than static texts of course, but the advantage largely justify it : accessing an array with its natural key is pretty straight forward for the php processor, the concern is more the memory consumed in keeping this array during the construction of the page, so it has to remain small, and loaded the later possible.
Back to top
qspy
Board Member



Joined: 03 Nov 2009

Posts: 10



PostPosted: Thu Nov 05, 2009 10:32 pm 
Post subject: Re: template.php to statically write language vars to cache

We need only 1 language, so ... icon_smile.gif we could do that static, anyone? maybe some point to where start coz i do a lot now (like solving hdd bottleneck).
Back to top
Acaria
Board Member



Joined: 20 Feb 2009

Posts: 238



PostPosted: Fri Nov 06, 2009 12:29 am 
Post subject: Re: template.php to statically write language vars to cache

You'd have to go in and replace every single call to a language file with static text. Considering PhpBB basically uses lang lines for upwards of 80% of all text generated from Php files, you'll be spending a loooong time typing.
Back to top
Dog Cow
Board Member



Joined: 18 Nov 2008

Posts: 378


flag
PostPosted: Fri Nov 06, 2009 5:21 pm 
Post subject: Re: template.php to statically write language vars to cache

There are some pit-falls to this method. Not all of the 'L_*' variables are static.

See here: http://www.phpbb.com/community/viewtopic.php?f=16&t=810295

_________________
Moof! Email me: dog_cow@macgui.com
Inside Allerton Park Lincoln's Tomb, Oak Ridge Cemetery, Springfield IL Mac 512K Blog
Back to top
qspy
Board Member



Joined: 03 Nov 2009

Posts: 10



PostPosted: Fri Nov 06, 2009 9:56 pm 
Post subject: Re: template.php to statically write language vars to cache

Dog Cow wrote:
There are some pit-falls to this method. Not all of the 'L_*' variables are static.

See here: http://www.phpbb.com/community/viewtopic.php?f=16&t=810295


True not all, but this speedy templates messing my simple subforums and viewtopic.
Back to top
Display posts from previous:   
Register or Login to Post    Index » MOD Requests  Previous TopicPrint TopicNext Topic
Page 1 of 1 All times are GMT
 
Jump to:  

Index • About • FAQ • Rules • Privacy • Search •  Register •  Login 
Not affiliated with or endorsed by the phpBB Group
Powered by phpBB2 © phpBB Group
Generated in 0.0118 seconds using 15 queries. (SQL 0.0022 Parse 0.0002 Other 0.0094)
phpBB Customizations by the phpBBDoctor.com
Template Design by DeLFlo and MomentsOfLight.com Moments of Light Logo