Menu separator?

Gesperrt
djavet
Beiträge: 264
Registriert: Do 22. Jan 2004, 11:31
Kontaktdaten:

Menu separator?

Beitrag von djavet »

Hello,

It is possible to have menu like the "Service Navigation" but with separator?
Like this: Menu1 | Menu2 | Menu3 | Menu4

Note that their is no "pipe" at the end! BTW it's the sense of my question ;o)
I wish to have a pipe as separator or a pix.

Is that possible?
Exemple:
-> http://www.swissveg.com/site/Main.php

Many thx in advance, Dominique
emergence
Beiträge: 10653
Registriert: Mo 28. Jul 2003, 12:49
Wohnort: Austria
Kontaktdaten:

Beitrag von emergence »

yes edit
cms/templates/hilfsnavi.html like this

Code: Alles auswählen

<table border="0" cellspacing="0" cellpadding="0">
         <tr><td style="border: 0px; border-top:1px; border-color: #F7C473; border-style: solid"><img src="wuerfel.gif" width="15" height="15" border="0"></td>
     <!-- BEGIN:BLOCK -->
      <td style="border: 0px; border-top:1px; border-color: #F7C473; border-style: dashed; background-color: #FCF2D5; padding-left:20px"><img src="images/wuerfel.gif">
       <a class="klein" href="{HREF}" target="{TARGET}">{NAME}</a></td><td> | </td>
    <!-- END:BLOCK -->
  </tr>
</table>
djavet
Beiträge: 264
Registriert: Do 22. Jan 2004, 11:31
Kontaktdaten:

Beitrag von djavet »

Hello,

I've think to that, but I search to remove the last pipe...
Like this :
menu1 | menu2 | menu 3 | menu 4

And not:
menu1 | menu2 | menu 3 | menu 4 | <--

Any suggestion?
I use the standard module:
Input:

Code: Alles auswählen

// selected category
$selected = "CMS_VALUE[0]";

echo "<table cellspacing=\"0\" cellpadding=\"10\" border=\"0\">
        <tr valign=\"top\">
          <td>Kategorie wählen:</td>
          <td>
            <select name=\"CMS_VAR[0]\">";
            if($selected!="0" && $selected!=""){
             echo"<option value=\"0\">--- kein ---</option>";

            }else{
            echo"<option selected=\"selected\" value=\"0\">--- kein ---</option>";
            }

            // fetch all categorys
            $query = "SELECT A.idcat, A.level, C.name FROM ".$cfg["tab"]["cat_tree"]." AS A, ".
                     $cfg["tab"]["cat"]." AS B,  ".$cfg["tab"]["cat_lang"]." AS C WHERE A.idcat=B.idcat ".
                     "AND B.idcat=C.idcat AND C.idlang='$lang' AND B.idclient='$client' ".
                     "AND C.visible=1 ORDER BY A.idtree";
            // execute query
            $db->query($query);

            // loop result and build the options
            while ($db->next_record()) {

              // indent spacer
              $spaces = "|";

              // how many levels
              $levels = $db->f("level");

              for ($i = 0; $i < $levels; $i ++) {
                // add 2 spaces for every level
                $spaces = $spaces . "--";

              } // end for
              
              $spaces .= ">";


              if ($selected == $db->f("idcat")) {
                // selected category
                echo "<option selected=\"selected\" value=\"". $db->f("idcat") ."\">". $spaces . $db->f("name") ."</option>";

              } else {
                // category
                echo "<option value=\"". $db->f("idcat") ."\">". $spaces . $db->f("name") ."</option>";

              } // end if

            } // end while

echo "      </select>";

echo "    </td>
        </tr>
      </table>";
Output:

Code: Alles auswählen

<?php

include_once($cfg["path"]["contenido"].$cfg["path"]["includes"]."functions.con.php");

$catStart = "CMS_VALUE[0]";

if ($catStart != "") {
  $catIds = conDeeperCategoriesArray($catStart);

  echo '<table cellpadding="0" cellspacing="0" border="0"><tr>';
  echo '<td><img src="images/wuerfel.gif"></td>';

  if ( is_array($catIds) ) {

    foreach($catIds as $key=>$val) {
      // Ersten Eintrag ueberspringen, weil das der Menupunkt selbst ist
      // und nicht angezeigt werden soll.
      if ($key != 0) {

        $sql = "SELECT CAT.idcat AS idcat, name FROM ".
               $cfg["tab"]["cat"]." AS CAT, ".
               $cfg["tab"]["cat_lang"]." AS CATLANG 
               WHERE CAT.idcat = ".$val."
               AND CAT.idcat = CATLANG.idcat
               AND CATLANG.idlang = '$lang'
               AND CATLANG.visible = '1'";

        $db->query($sql);


        while ( $db->next_record() ) {
          echo '<td height="21" class=".navigation" style="border: 0px; border-top:1px; border-color: #F7C473; border-style: dashed; background-color: #FFFFFF; padding-left:7px; padding-right:7px;">
          <a class="klein" href="front_content.php?idcat='.$db->f("idcat").'">'.$db->f("name").'</a></td>';
        } // end while
      } // if
    }  // end foreach
  } // end if (is_array)

  echo '</tr></table>';

}
?>
I dont' find where the template "cms/templates/hilfsnavi.html" is linked into the ouput code...

Regards, Dom
emergence
Beiträge: 10653
Registriert: Mo 28. Jul 2003, 12:49
Wohnort: Austria
Kontaktdaten:

Beitrag von emergence »

replace in output

Code: Alles auswählen

        while ( $db->next_record() ) { 
          echo '<td height="21" class=".navigation" style="border: 0px; border-top:1px; border-color: #F7C473; border-style: dashed; background-color: #FFFFFF; padding-left:7px; padding-right:7px;"> 
          <a class="klein" href="front_content.php?idcat='.$db->f("idcat").'">'.$db->f("name").'</a></td>'; 
        } // end while 
with

Code: Alles auswählen

        $tmp_counter = 0;
        while ( $db->next_record() ) { 
          if ($tmp_counter != 0) echo "<td> | </td>";
          echo '<td height="21" class=".navigation" style="border: 0px; border-top:1px; border-color: #F7C473; border-style: dashed; background-color: #FFFFFF; padding-left:7px; padding-right:7px;"> 
          <a class="klein" href="front_content.php?idcat='.$db->f("idcat").'">'.$db->f("name").'</a></td>';
          $tmp_counter++; 
        } // end while 
should work ;-)
djavet
Beiträge: 264
Registriert: Do 22. Jan 2004, 11:31
Kontaktdaten:

Beitrag von djavet »

Hello,

Must have a bug ;o)
I must set : $tmp_counter = 1 and not to $tmp_counter = 0 to work.
The last pipe is removed, but now I've a nice pipe at the begining...
and I dont' wish to start my menu with a pipe...

Sorry, I'm not a php master....
I appreciate the way you code ;o)

Regards; Dom
emergence
Beiträge: 10653
Registriert: Mo 28. Jul 2003, 12:49
Wohnort: Austria
Kontaktdaten:

Beitrag von emergence »

other version:

Code: Alles auswählen

        $tmp_counter = 0; 
          if ($tmp_counter != 0) echo "<td> | </td>"; 
          $tmp_counter++; 
        while ( $db->next_record() ) { 
          echo '<td height="21" class=".navigation" style="border: 0px; border-top:1px; border-color: #F7C473; border-style: dashed; background-color: #FFFFFF; padding-left:7px; padding-right:7px;"> 
          <a class="klein" href="front_content.php?idcat='.$db->f("idcat").'">'.$db->f("name").'</a></td>'; 
        } // end while 
Darth-Vader
Beiträge: 661
Registriert: So 25. Jan 2004, 19:06
Wohnort: Stuttgart-Bad Cannstatt
Kontaktdaten:

Beitrag von Darth-Vader »

*g*
djavet
Beiträge: 264
Registriert: Do 22. Jan 2004, 11:31
Kontaktdaten:

Beitrag von djavet »

:cry:
Same problem...:
-> http://www.metadelic.com/dev/contenido/cms/

Code: Alles auswählen

|  Home |  Impressum |  Kontakt 
See at the top navigation.
Someone told about a "join" function. Do you know what it is?

Regards, Dom
emergence
Beiträge: 10653
Registriert: Mo 28. Jul 2003, 12:49
Wohnort: Austria
Kontaktdaten:

Beitrag von emergence »

put the
$tmp_counter = 0;

before the
foreach($catIds as $key=>$val) {
djavet
Beiträge: 264
Registriert: Do 22. Jan 2004, 11:31
Kontaktdaten:

Beitrag von djavet »

Yeahaahah thx a lot.
It's working well now.

Except one thing:
If you have sub-categories, there is always a "|" at the end, but id you use a 1 level category (like Hilfenavigation), no problem.
Maybe it's due to the SQL select I think. Idea?

Depending the use of this kind of use of the menu, it's a little "tricky"....

BTW -> Many thanks,
Dom
emergence
Beiträge: 10653
Registriert: Mo 28. Jul 2003, 12:49
Wohnort: Austria
Kontaktdaten:

Beitrag von emergence »

i sould always test my code before i post it ;-)
djavet
Beiträge: 264
Registriert: Do 22. Jan 2004, 11:31
Kontaktdaten:

Beitrag von djavet »

Yop!
All is working perfect!
Forget my last comment concerning the sub-category, my fault :oops:

BTW, that's the way I learn!

Here's the full code with correction:

INPUT:

Code: Alles auswählen

/***********************************************
* CONTENIDO MODUL - INPUT
*
* Modulname   :     Navigation with separator, 1 level horizontal
*                   - Adapt to Contenido V4.4
************************************************/
// selected category
$selected = "CMS_VALUE[0]";

echo "<table cellspacing=\"0\" cellpadding=\"10\" border=\"0\">
        <tr valign=\"top\">
          <td>Kategorie wählen:</td>
          <td>
            <select name=\"CMS_VAR[0]\">";
            if($selected!="0" && $selected!=""){
             echo"<option value=\"0\">--- kein ---</option>";

            }else{
            echo"<option selected=\"selected\" value=\"0\">--- kein ---</option>";
            }

            // fetch all categorys
            $query = "SELECT A.idcat, A.level, C.name FROM ".$cfg["tab"]["cat_tree"]." AS A, ".
                     $cfg["tab"]["cat"]." AS B,  ".$cfg["tab"]["cat_lang"]." AS C WHERE A.idcat=B.idcat ".
                     "AND B.idcat=C.idcat AND C.idlang='$lang' AND B.idclient='$client' ".
                     "AND C.visible=1 ORDER BY A.idtree";
            // execute query
            $db->query($query);

            // loop result and build the options
            while ($db->next_record()) {

              // indent spacer
              $spaces = "|";

              // how many levels
              $levels = $db->f("level");

              for ($i = 0; $i < $levels; $i ++) {
                // add 2 spaces for every level
                $spaces = $spaces . "--";

              } // end for
              
              $spaces .= ">";


              if ($selected == $db->f("idcat")) {
                // selected category
                echo "<option selected=\"selected\" value=\"". $db->f("idcat") ."\">". $spaces . $db->f("name") ."</option>";

              } else {
                // category
                echo "<option value=\"". $db->f("idcat") ."\">". $spaces . $db->f("name") ."</option>";

              } // end if

            } // end while

echo "      </select>";

echo "    </td>
        </tr>
      </table>";
OUTPUT:

Code: Alles auswählen

<?php
/***********************************************
* CONTENIDO MODUL - OUTPUT
*
* Modulname   :     Navigation with separator, 1 level horizontal
*                   - Adapt to Contenido V4.4
************************************************/
include_once($cfg["path"]["contenido"].$cfg["path"]["includes"]."functions.con.php");

$catStart = "CMS_VALUE[0]";

if ($catStart != "") {
  $catIds = conDeeperCategoriesArray($catStart);

  echo '<table cellpadding="0" cellspacing="0" border="1"><tr>';

  if ( is_array($catIds) ) {
 $tmp_counter = 0;
    foreach($catIds as $key=>$val) {
      // Ersten Eintrag ueberspringen, weil das der Menupunkt selbst ist
      // und nicht angezeigt werden soll.
      if ($key != 0) {

        $sql = "SELECT CAT.idcat AS idcat, name FROM ".
               $cfg["tab"]["cat"]." AS CAT, ".
               $cfg["tab"]["cat_lang"]." AS CATLANG 
               WHERE CAT.idcat = ".$val."
               AND CAT.idcat = CATLANG.idcat
               AND CATLANG.idlang = '$lang'
               AND CATLANG.visible = '1'";

        $db->query($sql);


        
          if ($tmp_counter != 0) echo "<td>&nbsp;|&nbsp;</td>"; 
          $tmp_counter++; 
        while ( $db->next_record() ) { 
          echo '<td><a class="klein" href="front_content.php?idcat='.$db->f("idcat").'">'.$db->f("name").'</a></td>'; 
        } // end while 
      } // if
    }  // end foreach
  } // end if (is_array)

  echo '</tr></table>';

}
?>
A great thx to Emergence for his help!

Regards, Dominique
djavet
Beiträge: 264
Registriert: Do 22. Jan 2004, 11:31
Kontaktdaten:

Beitrag von djavet »

I found a little bug :(

You have a menu:
menu1 | menu2 | menu3 | menu4 | menu5

And when you disable the menu2 and menu3 you have:
menu1 | | | menu4 | menu5

Gasp! Any idea?

Regards, Dom
emergence
Beiträge: 10653
Registriert: Mo 28. Jul 2003, 12:49
Wohnort: Austria
Kontaktdaten:

Beitrag von emergence »

hmm... change

Code: Alles auswählen

          if ($tmp_counter != 0) echo "<td>&nbsp;|&nbsp;</td>"; 
          $tmp_counter++; 
        while ( $db->next_record() ) { 
-> to

Code: Alles auswählen

        while ( $db->next_record() ) { 
          if ($tmp_counter != 0) echo "<td>&nbsp;|&nbsp;</td>"; 
          $tmp_counter++;
not testet...
djavet
Beiträge: 264
Registriert: Do 22. Jan 2004, 11:31
Kontaktdaten:

Beitrag von djavet »

Yop!
Another bug corrected :D
Great thanks for the help.

Regards, Dom
Gesperrt