Page 1 of 2

New row based navigation

Posted: Sun 11. Apr 2004, 12:21
by Oliver Georgi
[UPDATE] 12-04-2004

See Download
http://www.phpwcms.de/index.php?download

There is a small patch available.

Usage:
{NAV_ROW} returns a row based menu starting at site level 0 including the HOME link

{NAV_ROW:CURRENT:1} row based menu starting at CURRENT level including the CURRENT structure level name

{NAV_ROW:CURRENT:0} row based menu starting at CURRENT level without the CURRENT structure level name

{NAV_ROW:ID:1} row based menu starting at given structure level ID including the structure level name

{NAV_ROW:ID:0} row based menu starting at given structure level ID without the structure level name


--------------------------------------------------------------------



Just the beginning of introducing a very simple but effective row based navigation menu:

New replacement tags:
{NAV_ROW} = full navigation of top level 0 including HOME
{NAV_ROW_NOHOME} = same as above without HOME


put in content.func.inc.php around line 275 (after breadcrum replacement):

Code: Select all

// -------------------------------------------------------------

// Simple row based navigation
if( ! ( strpos($content["all"],'{NAV_ROW')===false ) ) {
	$content["all"] = str_replace('{NAV_ROW}', nav_level_row(0), $content["all"]);
	$content["all"] = str_replace('{NAV_ROW_NOHOME}', nav_level_row(0,0), $content["all"]);
}

// -------------------------------------------------------------
Add at the end of front.func.inc.php:

Code: Select all

// -------------------------------------------------------------

function nav_level_row($act_cat_id, $show_home=1) {
	//returns a simple row based navigation
	
	$nav = '';
	
	if($show_home) {
		if($GLOBALS['content']["cat_id"] == $act_cat_id) {
			$before = $GLOBALS['template_default']["nav_row"]["link_before_active"];
			$after  = $GLOBALS['template_default']["nav_row"]["link_after_active"];
		} else {
			$before = $GLOBALS['template_default']["nav_row"]["link_before"];
			$after  = $GLOBALS['template_default']["nav_row"]["link_after"];
		}
		$nav .= $before;
		$nav .= '<a href="index.php?';
		$nav .= ($GLOBALS['content']['struct'][$act_cat_id]['acat_alias']) ? html_specialchars($GLOBALS['content']['struct'][$act_cat_id]['acat_alias']) : 'id='.$act_cat_id.',0,0,1,0,0';
		$nav .= '">'.html_specialchars($GLOBALS['content']['struct'][$act_cat_id]['acat_name']).'</a>';
		$nav .= $after;
	}
	
	foreach($GLOBALS['content']['struct'] as $key => $value) {
		if($GLOBALS['content']['struct'][$key]["acat_struct"] == $act_cat_id && $key != $act_cat_id && !$GLOBALS['content']['struct'][$key]['acat_hidden']) {
			
			if($nav) $nav .= $GLOBALS['template_default']["nav_row"]["between"];
			
			if($GLOBALS['content']["cat_id"] == $key) {
				$before = $GLOBALS['template_default']["nav_row"]["link_before_active"];
				$after  = $GLOBALS['template_default']["nav_row"]["link_after_active"];
			} else {
				$before = $GLOBALS['template_default']["nav_row"]["link_before"];
				$after  = $GLOBALS['template_default']["nav_row"]["link_after"];
			}
			
			$nav .= $before;
			$nav .= '<a href="index.php?';
			$nav .= ($GLOBALS['content']['struct'][$key]['acat_alias']) ? html_specialchars($GLOBALS['content']['struct'][$key]['acat_alias']) : 'id='.$key.',0,0,1,0,0';
			$nav .= '">'.html_specialchars($GLOBALS['content']['struct'][$key]['acat_name']).'</a>';
			$nav .= $after;
		}
	}
	$nav = $GLOBALS['template_default']["nav_row"]["before"].$nav.$GLOBALS['template_default']["nav_row"]["after"];
	return $nav;
}

// -------------------------------------------------------------
add at the end of conf.template_default.inc.php:

Code: Select all

// row based navigation
$template_default["nav_row"]["before"]				= '';
$template_default["nav_row"]["after"]				= '';
$template_default["nav_row"]["between"]				= ' | ';
$template_default["nav_row"]["link_before"]			= '';
$template_default["nav_row"]["link_after"]			= '';
$template_default["nav_row"]["link_before_active"]	= '<span style="text-decoration:none;font-weight:bold;">';
$template_default["nav_row"]["link_after_active"]	= '</span>';
This is a sample for table based row:

Code: Select all

// row based navigation
$template_default["nav_row"]["before"]				= '<table cellspacing="0" cellpadding="3" border="0" bgcolor="#FFFFFF"><tr>';
$template_default["nav_row"]["after"]				= '</tr></table>';
$template_default["nav_row"]["between"]				= "\n";
$template_default["nav_row"]["link_before"]			= '<td>';
$template_default["nav_row"]["link_after"]			= '</td>';
$template_default["nav_row"]["link_before_active"]	= '<td bgcolor="#DDDDDD" style="text-decoration:none;font-weight:bold">';
$template_default["nav_row"]["link_after_active"]	= '</td>';

Have fun:
Oliver

Posted: Sun 11. Apr 2004, 14:20
by Jan212
Year, cool stuff. Thank you from my side - and nice Easter days to all

Posted: Sun 11. Apr 2004, 14:24
by nekket
Great stuff! Works fine!

Posted: Sun 11. Apr 2004, 21:49
by pSouper
hehe OG posting a Hack :D
maybe he has crossed over to the dark side

i love Irony

Posted: Sun 11. Apr 2004, 23:07
by Jan212
are we the dark side :shock: :?: :wink:

Posted: Mon 12. Apr 2004, 00:32
by adam
Great enhancement!

Is it possible to use this horizontal navigation bar also for submenus? How could I realize this?


Adam

Posted: Mon 12. Apr 2004, 01:33
by Oliver Georgi
It is possible yet - all you have to do is extend replacement tag check in content.func.inc.php like this:

Code: Select all

// Simple row based navigation
if( ! ( strpos($content["all"],'{NAV_ROW')===false ) ) {
	$content["all"] = str_replace('{NAV_ROW}', nav_level_row(0), $content["all"]);
	$content["all"] = str_replace('{NAV_ROW_NOHOME}', nav_level_row(0,0), $content["all"]);
	$content["all"] = str_replace('{NAV_ROW_CURRENT}', nav_level_row($content["cat_id"],0), $content["all"]);
	$content["all"] = preg_replace('/\{NAV_ROW:(\d+)\}/e','nav_level_row($1,0);',$content["all"]);
}
Maybe I will change replacement tag names again (because of the NOHOME attribute).

Regards
Oliver

Posted: Mon 12. Apr 2004, 03:32
by ionrock
This is also doable with css using my nav list hack :) just do something like this in the css

Code: Select all

#divId ul {
     display: inline;
}
I am impressed with the array work Oliver :) Good job!

Posted: Mon 12. Apr 2004, 10:18
by Fulvio Romanin
this may be an obvious request but, please, Oliver, include this as a default in the next release...

Posted: Mon 12. Apr 2004, 12:35
by Oliver Georgi
it will ;-)

Posted: Mon 12. Apr 2004, 15:08
by adam
Exactly what I have been looking for! Thank you!

PHPWCMS is the best cms I have ever used.........weiter so! :wink: (don't know that in English)

Posted: Mon 12. Apr 2004, 17:58
by Oliver Georgi
I have made some changes - I will release a small patch now.

Patch is out now - see http://www.phpwcms.de/index.php?download

Regards
Oliver

Posted: Mon 12. Apr 2004, 22:46
by hofisoft
ähm, kleines prob.
Patch installiert, läuft auch problemlos
Aber jetzt hab ich das problem das ich nen artikel im spaw nimmer editieren kann, bzw. er zeigt mir nimmer den alten text im editor an, sondern ne leere seite obwohl da was drinstehen müßte. Also editor usw. alles wird angezeigt nur der text ned der eigendlich im artikel drinstehen müßte.
Kanns sein das ich irgendwas vergessen hab ?

Posted: Mon 12. Apr 2004, 22:58
by Oliver Georgi
Hm - true:

please change back line 8 in script.js.php in include/inc_ext/spaw/class to:

Code: Select all

for(i=0;i<spaw_editors.lenght;i++)
Sorry - I have to check that later again.

[UPDATE]
I have updated the patch files - old script.js.php is included again. SPAW developer contacted...

Regards
Oliver

Posted: Mon 12. Apr 2004, 23:28
by hofisoft
ahhh, super, vielen dank, ein problemchen weniger ;)