Do you want to have a image based navigation like here http://www.netzelf.de or here: http://www.hoerspiel-leipzig.de
(it's a category-based navigation)
So you can do this in your phpwcms-installation:
- Create a empty php-file in template/inc_script/frontend_render and name it how you want.
Write this code to the new file:
Code: Select all
<?php
// ----------------------------------------------------------------
// obligate check for phpwcms constants
if (!defined('PHPWCMS_ROOT')) {
die("You Cannot Access This Script Directly, Have a Nice Day.");
}
// ----------------------------------------------------------------
$rp_tag = "{MY_LEVEL_NAV}";
if( ! ( strpos($content["all"],$rp_tag)===false ) ) {
$gt_link_style = "navi";
$gt_hover_style = "navi_hover"; //Leave it empty if no Hover-Style is needed
$gt_active_style = "navi_active";
$use_title = 0;
$cat_before = "";
$cat_after = "";
$cat_between = '<img src="img/leer.gif" border="0" width="18" height="1" alt="" />';
$cat_transform = 2; // 0=none 1=lowercase 2=uppercase
$link_attributes = ""; //additional attributes for the link-tag eg. ' target="_blank" class="link_nav"'
$img_attributes = ""; //additional attributes for the image-tag eg. ' border="0" class="img_nav"'
$struct = getStructureChildData(0);
foreach($struct as $value) {
if ($cat_transform == 2)
{
$name = strtoupper($value["acat_name"]);
}elseif ($cat_transform == 2)
{
$name = strtolower($value["acat_name"]);
}else
{
$name = $value["acat_name"];
}
$string .= ($value["acat_id"] == $GLOBALS["content"]["cat_id"]) ? "{im:".$value["acat_alias"]."}{GT:".$gt_active_style."}".$name."{/GT}{/im}" : "{im:".$value["acat_alias"]."}{GT:".$gt_link_style."}".$name."{/GT}{/im}";
if (!empty($gt_hover_style))
{
$string .= "{imh:".$value["acat_alias"]."}{GT:".$gt_hover_style."}".$name."{/GT}{/imh}";
}
}
$content["all"] .= $string;
require_once ('include/inc_module/mod_graphical_text/inc_front/gt.func.inc.php');
$phpwcms["gt_mod"] = false;
$content["all"] = preg_replace_callback('/\{im:(.+?)\}<img src="(.*?)" alt="(.*?)" title="(.*?)" width="(.*?)" height="(.*?)" border="0" \/>\{\/im\}/is', 'get_link_img', $content["all"]);
if (!empty($gt_hover_style))
{
$content["all"] = preg_replace_callback('/\{imh:(.+?)\}<img src="(.*?)" alt="(.*?)" title="(.*?)" width="(.*?)" height="(.*?)" border="0" \/>\{\/imh\}/is', 'get_hover_img', $content["all"]);
}
$idi = 0;
foreach ($GLOBALS["img_nav"] as $img)
{
if (!empty($gt_hover_style))
{
$js .= " image_url[$idi] = '".$img["hsrc"]."';\n";
$cat_behaviour = " onmouseover=\"switch_img($idi);\" onmouseout=\"switch_img($idi);\"";
}
$cat = $cat_before.'<a href="index.php?'.$id.'"'.$cat_behaviour.$link_attributes.'><img src="'.$img["src"].'" alt="'.$img["name"];
$cat .= ($use_title) ? '" title="'.$img["name"] : "";
$img_link[] = $cat.'" width="'.$img["width"].'" height="'.$img["height"].'"'.$img_attributes." id=\"img_nav_$idi\" /></a>$cat_after";
$idi++;
}
$idi--;
$img_link = implode($cat_between, $img_link);
$content["all"] = str_replace($rp_tag, $img_link, $content["all"]);
if (!empty($gt_hover_style)) {
$block["htmlhead"] .= '<script type="text/javascript">
<!--
if (document.images)
{
preload_image_object = new Image();
image_url = new Array();
'.$js.'
var i = 0;
for(i=0; i<='.$idi.'; i++)
preload_image_object.src = image_url[i];
}
exc_img = new Array(); exc_img[0] = -1;
function switch_img(id) {
if (exc_img[0] == id) {
document.getElementById("img_nav_" + id).src = exc_img[1];
exc_img[0] = -1;
}else{
exc_img[0] = id;
exc_img[1] = document.getElementById("img_nav_" + id).src;
document.getElementById("img_nav_" + id).src = image_url[id];
}
}
//-->
</script>';
}
}
function get_link_img($matches) {
$GLOBALS["img_nav"][$matches[1]]["name"] = $matches[3];
$GLOBALS["img_nav"][$matches[1]]["src"] = $matches[2];
$GLOBALS["img_nav"][$matches[1]]["width"] = $matches[5];
$GLOBALS["img_nav"][$matches[1]]["height"] = $matches[6];
return "";
}
function get_hover_img($matches) {
$GLOBALS["img_nav"][$matches[1]]["hsrc"] = $matches[2];
return "";
}
?>
- -Create GT-Styles for link, hover and active and change the names for the Styles in the script.
-Use {MY_LEVEL_NAV} or the tag you specified whereever you want in your template.
-READY

Changed because of a useless function: foreach ($GLOBALS["img_nav"] as $id => $img) is now foreach ($GLOBALS["img_nav"] as $img)