Display of a specific submenu level

Post custom hacks and enhancements for phpwcms here only. Maybe some of these things will be included in official release later.

Display of a specific submenu level

Postby tomtom3000 on Thu Dec 04, 2008 15:17

First: Kudos to Oliver for this cms-framework. We searched for a replacement of T3, found phpwcms, decided to test it with 2 websites we have already realised in T3. We are pleaseantly surprized about stability, flexibility and embedding time.

In our opinion there is optimisation need in page generation time, visualisation of the content parts in the backend and the menu replacement tags. We made some work-arounds, will post our results here from time to time. Please excuse if similar solutions are posted somewhere else on this forum -> we are one-week-newbies and have no complete overview ;-). The snippets just helped us to realize our projects, so we think they are also helpful for others.

Custom menu: We needed a special menu showing ONLY the second level menu items of the actual selected group. For example:

Code: Select all
[0] Home
    [1] About Us
    [2] Contact
    [3] News
    [4] Product
         [] Product 1-1
         [] Product 1-2
         [] Product 1-2-1
               [] Product 1-2-2
               [] Product 1-2-3
         [] Product 1-3
         [] Product 1-4
    [5] Company
         [] Company 1-1
         [] Company 1-2   
         [] Company 1-3
         [] Company 1-3-1
               [] Company 1-3-2
               [] Company 1-3-3
         [] Company 1-4
         [] Company 1-5
         [] Company 1-5-1
    [6] Contact


If the actual page is Company 1-3-1 (third level) we only want to show Company 1-1...Company 1-5 in the menu. If the actual page is the Product main page we only want to show Product 1-1...Product 1-4. Same as we are in Product 1-1 or 1-2-3.

Problem: If you are in a sub-menu the $Globals dont delivers the specific id of the first level page. But we can read out the ["acat_struct"] to get this (for better understanding we dont nest it here in a for... loop and request only 7 levels up):

Code: Select all
[PHP]
$actual_ebene = $GLOBALS[content][cat_id];   
$request_ebene = $actual_ebene;
$ebene_ho1 = $GLOBALS[content][struct][$request_ebene]["acat_struct"];
if($ebene_ho1 > 0){$request_ebene = $ebene_ho1;}
$ebene_ho2 = $GLOBALS[content][struct][$ebene_ho1]["acat_struct"];
if($ebene_ho2 > 0){$request_ebene = $ebene_ho2;}
$ebene_ho3 = $GLOBALS[content][struct][$ebene_ho2]["acat_struct"];
if($ebene_ho3 > 0){$request_ebene = $ebene_ho3;}
$ebene_ho4 = $GLOBALS[content][struct][$ebene_ho3]["acat_struct"];
if($ebene_ho4 > 0){$request_ebene = $ebene_ho4;}
$ebene_ho5 = $GLOBALS[content][struct][$ebene_ho4]["acat_struct"];
if($ebene_ho5 > 0){$request_ebene = $ebene_ho5;}
$ebene_ho6 = $GLOBALS[content][struct][$ebene_ho5]["acat_struct"];
if($ebene_ho6 > 0){$request_ebene = $ebene_ho6;}
$ebene_ho7 = $GLOBALS[content][struct][$ebene_ho6]["acat_struct"];
if($ebene_ho7 > 0){$request_ebene = $ebene_ho7;}

$GLOBALS["spec_hauptmenuebene"] = $request_ebene;
[/PHP]


Now we have the ID of the first level in the new $GLOBALS["spec_hauptmenuebene"] and use it in the page like this:

Code: Select all
[PHP]
$hauptmenuebene=$GLOBALS["spec_hauptmenuebene"];
$keys = array_keys($GLOBALS[content][struct]);
$coun = count($GLOBALS[content][struct]);

for ($a = 0; $a < $coun; $a++) {
   if($GLOBALS[content][struct][$keys[$a]][acat_struct] == $hauptmenuebene && $GLOBALS[content][struct][$act_area][acat_hidden] ==0){
      $subm_arr[] = $GLOBALS[content][struct][$keys[$a]][acat_name];
      $subm_lnk[] = $GLOBALS[content][struct][$keys[$a]][acat_alias];
   }
}
if(isset($subm_arr)){
   $lk = 0;
   foreach ($subm_arr as $value) {
      echo "<li><a href=index.php?".$subm_lnk[$lk].">".$value."</a></li>";
      $lk += 1;
   }
}
unset($subm_arr);
unset($subm_lnk);
[/PHP]
tomtom3000
 
Posts: 1
Joined: Thu Dec 04, 2008 15:09

Re: Display of a specific submenu level

Postby markus s on Fri Dec 05, 2008 15:06

did your already read this ?
http://forum.phpwcms.org/viewtopic.php?p=83839
search for "level lift"
moderator
Image
User avatar
markus s
Moderator
 
Posts: 407
Joined: Sat Dec 16, 2006 18:21
Location: Brixlegg / Tirol


Return to hacks & enhancements

Who is online

Users browsing this forum: Alexa [Bot] and 0 guests