2011-06-05, 15:35:06
(I submitted this to the svn...)
Every time a template calls get_component() the components.xml file is read. With GS bundled themes that's 3 file reads per rendered page, but could be even more...
I suggest making $components a global variable, and checking if it exists before loading the file.
Something like this:
PS: Opinions? Do you think of another way?
Every time a template calls get_component() the components.xml file is read. With GS bundled themes that's 3 file reads per rendered page, but could be even more...
I suggest making $components a global variable, and checking if it exists before loading the file.
Something like this:
Code:
function get_component($id) {
if (!array_key_exists('components', $GLOBALS)) {
global $components;
if (file_exists(GSDATAOTHERPATH.'components.xml')) {
$data = getXML(GSDATAOTHERPATH.'components.xml');
$components = $data->item;
}
} else {
global $components;
}
if (count($components) != 0) {
foreach ($components as $component) {
if ($id == $component->slug) {
eval("?>" . strip_decode($component->value) . "<?php ");
}
}
}
}
PS: Opinions? Do you think of another way?