Log in

View Full Version : Phrase system, part two


filburt1
02-28-2004, 04:01 PM
How would I go about fetching a phrase in code (i.e., not from within a template)?

I am using fetch_phrase(), but it seems to be adding a query for every phrase it translates:

SELECT text, languageid
FROM phrase
WHERE phrasetypeid = 500
AND varname = 'navbar_folders'AND languageid IN (-1, 0, 1)
Time before: 0.1310920715332
Time after: 0.13276600837708
Time taken: 0.0016739368438721

table type possible_keys key key_len ref rows Extra
phrase range name_lang_type,languageid name_lang_type 254 3 Using where

Query:

SELECT text, languageid
FROM phrase
WHERE phrasetypeid = 500
AND varname = 'navbar_filters'AND languageid IN (-1, 0, 1)
Time before: 0.13507008552551
Time after: 0.13678789138794
Time taken: 0.0017178058624268

table type possible_keys key key_len ref rows Extra
phrase range name_lang_type,languageid name_lang_type 254 3 Using where

...and so on for each phrase fetched in code.

Andreas
02-28-2004, 04:28 PM
That's what array $phrasegroups is for. Must be initalized before calling global.php so the phrases in this group will be cached.

Only use fetch_phrase or fetch_phrase_group when you really need to use a phrase(group) that has not been cached (which should rarely be the case).

Otherwise just use $vbphrase['yourphrase']

filburt1
02-28-2004, 04:30 PM
That's what array $phrasegroups is for. Must be initalized before calling global.php so the phrases in this group will be cached.

Only use fetch_phrase or fetch_phrase_group when you really need to use a phrase(group) that has not been cached (which should rarely be the case).

Otherwise just use $vbphrase['yourphrase']
I did set $phrasegroups:

$globaltemplates = array("vbms_navbar", "vbms_navbarbit");
$phrasegroups = array("vbms");

$vbphrase (the array) already contains all of the phrases from the appropriate phrase group, as well as the global templates?

Link14716
02-28-2004, 06:13 PM
$vbphrase contains all the global phrases as defined in I believe global.php, as well as all of the phrases from the phrasegroups defined in $phrasegroups at the top of the file.

filburt1
02-28-2004, 06:14 PM
Excellent, thank you. :)