within my page.tpl.php I have the following code which makes some trouble in the backend. Therefore I want to solve it the better way, with preprocess functions.
if (!path_is_admin(current_path())) {
$pathArray = explode('/', current_path());
if (!empty($pathArray)) {
$path_to_node = url("node/".$pathArray[1]);
$img = '<img src="'.$theme_path.'/images/default.png" alt="Default" />';
if (!empty($path_to_node)) {
$menuChildArray = explode('/', $path_to_node);
if (!empty($menuChildArray[2])) {
$menuParent = $menuChildArray[2];
switch($menuParent) {
case "one":
$img = '<img src="'.$theme_path.'/images/one.png" alt="Pic tne!" />';
break;
case "two":
default:
$img = '<img src="'.$theme_path.'/images/two.png" alt="Pic two!" />';
break;
}
}
print $img;
}
}
}
But how can I realize this? To try it, I did the following:
I added a template.php to the Theme folder and added:
function set2015_preprocess_page(&$variables) {
$variables['set2015_pics'] = 'test';
}
Within page.tpl.php I then did:
<?php
print $set2015_pics;
But nothing is getting printed... What am I doing wrong here?
Thank you!