New row based navigation

Post custom hacks and enhancements for phpwcms here only. Maybe some of these things will be included in official release later.
User avatar
Oliver Georgi
Site Admin
Posts: 9919
Joined: Fri 3. Oct 2003, 22:22
Contact:

New row based navigation

Post 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
Last edited by Oliver Georgi on Mon 12. Apr 2004, 18:29, edited 1 time in total.
Oliver Georgi | phpwcms Developer | GitHub | LinkedIn | Систрон
Jan212
Posts: 859
Joined: Wed 28. Jan 2004, 21:38
Location: Solingen
Contact:

Post by Jan212 »

Year, cool stuff. Thank you from my side - and nice Easter days to all
Regards/ Grüsse/ Groetjes - JAN212
------------------------------------------------
null212 - Büro für Kommunikation und Design
------------------------------------------------
Lyrikfetzen des Tages
1. Ist der Quelltext auch valide fragt Herr Müller ganz perfide.
2. Wat is dat een lekker ding.
3. Wer Vision hat soll zum Arzt gehen.
------------------------------------------------
User avatar
nekket
Posts: 613
Joined: Tue 18. Nov 2003, 15:46
Location: Baden-Baden
Contact:

Post by nekket »

Great stuff! Works fine!
User avatar
pSouper
Posts: 1552
Joined: Tue 11. Nov 2003, 15:45
Location: London
Contact:

Post by pSouper »

hehe OG posting a Hack :D
maybe he has crossed over to the dark side

i love Irony
Jan212
Posts: 859
Joined: Wed 28. Jan 2004, 21:38
Location: Solingen
Contact:

Post by Jan212 »

are we the dark side :shock: :?: :wink:
Regards/ Grüsse/ Groetjes - JAN212
------------------------------------------------
null212 - Büro für Kommunikation und Design
------------------------------------------------
Lyrikfetzen des Tages
1. Ist der Quelltext auch valide fragt Herr Müller ganz perfide.
2. Wat is dat een lekker ding.
3. Wer Vision hat soll zum Arzt gehen.
------------------------------------------------
adam
Posts: 28
Joined: Thu 18. Mar 2004, 16:46
Location: Neuried, Germany

Post by adam »

Great enhancement!

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


Adam
User avatar
Oliver Georgi
Site Admin
Posts: 9919
Joined: Fri 3. Oct 2003, 22:22
Contact:

Post 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
Oliver Georgi | phpwcms Developer | GitHub | LinkedIn | Систрон
ionrock
Posts: 279
Joined: Fri 20. Feb 2004, 17:04

Post 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!
User avatar
Fulvio Romanin
Posts: 394
Joined: Thu 4. Dec 2003, 11:12
Location: Udine, Italy
Contact:

Post by Fulvio Romanin »

this may be an obvious request but, please, Oliver, include this as a default in the next release...
Completeness is reached through subtraction, not through addition
User avatar
Oliver Georgi
Site Admin
Posts: 9919
Joined: Fri 3. Oct 2003, 22:22
Contact:

Post by Oliver Georgi »

it will ;-)
Oliver Georgi | phpwcms Developer | GitHub | LinkedIn | Систрон
adam
Posts: 28
Joined: Thu 18. Mar 2004, 16:46
Location: Neuried, Germany

Post 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)
User avatar
Oliver Georgi
Site Admin
Posts: 9919
Joined: Fri 3. Oct 2003, 22:22
Contact:

Post 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
Oliver Georgi | phpwcms Developer | GitHub | LinkedIn | Систрон
hofisoft
Posts: 23
Joined: Sat 10. Apr 2004, 00:17

Post 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 ?
User avatar
Oliver Georgi
Site Admin
Posts: 9919
Joined: Fri 3. Oct 2003, 22:22
Contact:

Post 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
Oliver Georgi | phpwcms Developer | GitHub | LinkedIn | Систрон
hofisoft
Posts: 23
Joined: Sat 10. Apr 2004, 00:17

Post by hofisoft »

ahhh, super, vielen dank, ein problemchen weniger ;)
Post Reply