Get the current site structure level

Get help with installation and running phpwcms here. Please do not post bug reports or feature requests here.
Post Reply
User avatar
Rainer G
Posts: 377
Joined: Wed 16. Feb 2005, 10:26
Location: Hannover - Germany
Contact:

Get the current site structure level

Post by Rainer G »

With:
{NAV_TABLE_COLUMN:integer}
can i set the beginning of the NavMenü.

With {NAV_ROW_CURRENT} starts the Menü with the next entry below. This will i do with the NAV_TABLE_COLUMN.

How can i get the current id to set in {NAV_TABLE_COLUMN:id}?

A good new replacement-tag for the future: {NAV_TABLE_CURRENT} :D
rk
Posts: 162
Joined: Sat 24. Apr 2004, 23:48
Location: Hannover, Germany
Contact:

Post by rk »

Try {NAV_LIST}, now available in the dev-release.

http://www.phpwcms.de/forum/viewtopic.php?p=32037#32037
Ralf
User avatar
Rainer G
Posts: 377
Joined: Wed 16. Feb 2005, 10:26
Location: Hannover - Germany
Contact:

Post by Rainer G »

I use the RC4 :-(, the dev only for testing.
Pappnase

Post by Pappnase »

hello

to get the id move the mouse over this icon in admin -> sitestructure, then you will see it.

Image
User avatar
Rainer G
Posts: 377
Joined: Wed 16. Feb 2005, 10:26
Location: Hannover - Germany
Contact:

Post by Rainer G »

doubleposting :x
Last edited by Rainer G on Mon 21. Feb 2005, 12:19, edited 1 time in total.
User avatar
Rainer G
Posts: 377
Joined: Wed 16. Feb 2005, 10:26
Location: Hannover - Germany
Contact:

Post by Rainer G »

Pappnase wrote:hello

to get the id move the mouse over this icon in admin -> sitestructure, then you will see it.

Image
Witzbold :-)

I will script this in the template/left with coding like this:

{NAV_TABLE_COLUMN:
[PHP]
echo $get_current_navid;
[/PHP]
integer}

I will use one template and not one for every subpage!

It will be look at this page from Pepe:
http://www.peperkorn-online.de/index.php

You understand me?
User avatar
Rainer G
Posts: 377
Joined: Wed 16. Feb 2005, 10:26
Location: Hannover - Germany
Contact:

Post by Rainer G »

anyone an idea?
Karla
Posts: 223
Joined: Tue 26. Oct 2004, 11:56

Post by Karla »

User avatar
Rainer G
Posts: 377
Joined: Wed 16. Feb 2005, 10:26
Location: Hannover - Germany
Contact:

Post by Rainer G »

With your help i have this written (it's not a good code, but it runs how i will):

Code: Select all

[PHP]
$id = $GLOBALS['content']['cat_id'];
$parent_id=$GLOBALS['content']['struct'][$id]['acat_struct'];

if ($id==0) {$top_id = $id;}			// Home
elseif ($parent_id==0) {$top_id = $id;}	// Sub 1
else {
 $id=$parent_id;
 $parent_id=$GLOBALS['content']['struct'][$id]['acat_struct'];
 if ($parent_id==0) {$top_id=$id;}		// Sub 2
 else {
  $id=$parent_id;
  $parent_id=$GLOBALS['content']['struct'][$id]['acat_struct'];
  if ($parent_id==0) {$top_id=$id;}	// Sub 3
  else {
   $id=$parent_id;
   $parent_id=$GLOBALS['content']['struct'][$id]['acat_struct'];
   if ($parent_id==0) {$top_id=$id;}	// Sub 4
  }
  // Add here next
 }
}
//echo "Top: ".$top_id." ID: ".$id." Parent: ".$parent_id;
if ($top_id > 0) {echo '{NAV_TABLE_COLUMN:'.$top_id.'}';}
[/PHP]
And for every additional sub structure, add this lines:

Code: Select all

  else {
   $id=$parent_id;
   $parent_id=$GLOBALS['content']['struct'][$id]['acat_struct'];
   if ($parent_id==0) {$top_id=$id;}	// Sub 4
  }
  // Add here next
:D :D :D :mrgreen: :D :D :D :mrgreen: :D :D :D
kiwix
Posts: 65
Joined: Fri 25. Feb 2005, 09:40

Post by kiwix »

Hi Rainer,

I used your code, but I thought it was a bit to difficult (and ugly :-) ).
So I tried to optimize it a bit. On my intsallation it seams to word and you you haven't to do the check for every sub level of your structure.

Code: Select all

[PHP]
$id        = $GLOBALS['content']['cat_id'];
$parent_id = $GLOBALS['content']['struct'][$id]['acat_struct'];
if ($id!=0) {
  while ($parent_id != 0):
    $id=$parent_id;
    $parent_id=$GLOBALS['content']['struct'][$id]['acat_struct'];
  endwhile;
}
if ($id > 0) {
  echo '{NAV_TABLE_COLUMN:'.$id.'}';
}
[/PHP]
Cheers
KiWiX
User avatar
Rainer G
Posts: 377
Joined: Wed 16. Feb 2005, 10:26
Location: Hannover - Germany
Contact:

Post by Rainer G »

Hi Kiwix!

Meanwhile i use my selfoptimized code:

Code: Select all

$id = $GLOBALS['content']['cat_id'];

 $parent_id=$GLOBALS['content']['struct'][$id]['acat_struct'];
 While ($parent_id<>0){
   $id=$parent_id;
   $parent_id=$GLOBALS['content']['struct'][$id]['acat_struct'];
 }

 if ($id > 0) {
  echo '{NAV_TABLE_COLUMN:'.$id.'}';
 }
8) 8) 8)
Post Reply