Zegnåt Wrote:mvlcek Wrote:BTW: a return after the eval would be beneficialWhat kind of return would you suggest?
I just meant a return directly after the eval. But as you mention it, in the I18N plugin I return, if the component exists or not:
Code:
function get_component($id) {
global $components;
if (func_num_args() > 1) { $args = func_get_args(); array_shift($args); }
if (!$components) {
if (file_exists(GSDATAOTHERPATH.'components.xml')) {
$data = getXML(GSDATAOTHERPATH.'components.xml');
$components = $data->item;
} else {
$components = array();
}
}
if (count($components) > 0) {
foreach ($components as $component) {
if ($id == $component->slug) {
eval("?>" . strip_decode($component->value) . "<?php ");
return true;
}
}
}
return false;
}
This way you can use code like this in your template (custom sidebar for specific pages):
Code:
<?php get_component('sidebar-'.return_page_slug()) || get_component('sidebar'); ?>