Navigation with sublayer

Gesperrt
mikamedia
Beiträge: 26
Registriert: Mo 30. Jun 2003, 11:07
Kontaktdaten:

Navigation with sublayer

Beitrag von mikamedia » Mo 24. Nov 2003, 16:19

Hi,

I have a navigation structure

1. Products
1.1 Product 1
1.2 Product 2
2. Services
2.1 Service 1
2.2 Service 2

I want to use a 'hauptnavigation' which always shows the second layer aswell without the need of clicking the categorie.

Example of website hauptnavigation:

Products
Product 1
Product 2
Services
Service 1
Service 2

Does anyone know how to do this?

Thanks !

John

agon
Beiträge: 83
Registriert: Mi 29. Okt 2003, 16:01
Kontaktdaten:

Beitrag von agon » Di 25. Nov 2003, 09:09

Hi,

take a look at the Input of e.g. the Modul "Artikelliste". There, the sql-query gives back all the categories. It should be easy to adapt this for your problem (e.g. with A.level="1" OR A.level="2").

Greetings
Andreas

ttb
Beiträge: 182
Registriert: So 26. Okt 2003, 19:54
Wohnort: Schwerin
Kontaktdaten:

Beitrag von ttb » Di 25. Nov 2003, 12:07

But how do I make a correct output of the navi? And how do I make it with the navigationtemplates?

agon
Beiträge: 83
Registriert: Mi 29. Okt 2003, 16:01
Kontaktdaten:

Beitrag von agon » Mi 26. Nov 2003, 09:15

Hello,

this should work:

Module: first two levels

Description: shows the first two levels (without 'home') of the navigation, using the nav*.html-files; based upon the navigation-module of Jan Legowski

Input: none

Output:

Code: Alles auswählen

<?php
echo '<table cellspacing="0" cellpadding="0" border="0">';

// template klasse includen
include_once($cfg["path"]["contenido"] . 'classes/class.template.php');

// template instanz
$tpl = new Template;

$sql = "SELECT CATTREE.idcat, CATTREE.level, CATLANG.name
 FROM ".$cfg["tab"]["cat_tree"]." AS CATTREE, ".$cfg["tab"]["cat"]." AS CAT, ".$cfg["tab"]["cat_lang"]." AS CATLANG
 WHERE CATTREE.idcat=CAT.idcat AND CAT.idcat=CATLANG.idcat AND CATLANG.idlang='$lang' AND CAT.idclient='$client' AND CATLANG.visible=1
  AND (CATTREE.level='1' OR CATTREE.level='2')
 ORDER BY CATTREE.idtree";

$db->query($sql);

while ( $db->next_record() )
{
 $tpl->reset();
 $tpl->set('d', 'NAME',  $db->f("name"));
 $tpl->set('d', 'HREF',  $sess->url('front_content.php?idcat='.$db->f("idcat").'&client='.$client.'&la'.'ng='.$lang));
 $tpl->next();
 switch ($db->f("level"))
 {
  case 1:
   if ($idcat == $db->f("idcat"))
   {
    $tpl->generate('templates/navfirst_on.html');
   } else {
    $tpl->generate('templates/navfirst_off.html');
   }
   break;
  case 2:
   if ($idcat == $db->f("idcat"))
   {
    $tpl->generate('templates/navsecond_on.html');
   } else {
    $tpl->generate('templates/navsecond_off.html');
   }
   break;
 }
}

echo '</table>';

?>
The module could be extended by choosing the number of levels and the home-directory in the input-area.

Greetings
Andreas

ttb
Beiträge: 182
Registriert: So 26. Okt 2003, 19:54
Wohnort: Schwerin
Kontaktdaten:

Beitrag von ttb » Mi 26. Nov 2003, 11:06

Thanks! But the SQL-Statement selects the items of the 'Hilfsnavigation', too. :? How must I change the Statement that it works correctly?

agon
Beiträge: 83
Registriert: Mi 29. Okt 2003, 16:01
Kontaktdaten:

Beitrag von agon » Mi 26. Nov 2003, 11:22

Hello,

take the input-module of Jan Legowski's Navigation and then the following output-module:

Code: Alles auswählen

<?php

function catIsChildOf($id, $idparent) {
    global $cfg, $client, $lang;

    $db = new DB_Contenido;
    $parent = $id;
    while ( $parent != 0 ) {
        $sql = "SELECT a.parentid
                FROM ".$cfg["tab"]["cat"]." AS a, ".$cfg["tab"]["cat_lang"]." AS b
                WHERE a.idclient='".$client."' AND b.idlang='".$lang."' AND a.idcat=b.idcat AND a.idcat='".$parent."'";
        $db->query($sql);
        $db->next_record();
        $parent = $db->f("parentid");
        if ($parent == $idparent) {
            return true;
        }
    }
    return false;
}

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

// template klasse includen
include_once($cfg["path"]["contenido"] . 'classes/class.template.php');

// template instanz
$tpl = new Template;

$sql = "SELECT CATTREE.idcat, CATTREE.level, CATLANG.name
 FROM ".$cfg["tab"]["cat_tree"]." AS CATTREE, ".$cfg["tab"]["cat"]." AS CAT, ".$cfg["tab"]["cat_lang"]." AS CATLANG
 WHERE CATTREE.idcat=CAT.idcat AND CAT.idcat=CATLANG.idcat AND CATLANG.idlang='$lang' AND CAT.idclient='$client' AND CATLANG.visible=1
  AND (CATTREE.level='1' OR CATTREE.level='2')
 ORDER BY CATTREE.idtree";

$db->query($sql);

while ( $db->next_record() )
{
 if ( catIsChildOf($db->f("idcat"), CMS_VALUE[0]) )
 {
  $tpl->reset();
  $tpl->set('d', 'NAME',  $db->f("name"));
  $tpl->set('d', 'HREF',  $sess->url('front_content.php?idcat='.$db->f("idcat").'&client='.$client.'&la'.'ng='.$lang));
  $tpl->next();
  switch ($db->f("level"))
  {
   case 1:
    if ($idcat == $db->f("idcat"))
    {
     $tpl->generate('templates/navfirst_on.html');
    } else {
     $tpl->generate('templates/navfirst_off.html');
    }
    break;
   case 2:
    if ($idcat == $db->f("idcat"))
    {
     $tpl->generate('templates/navsecond_on.html');
    } else {
     $tpl->generate('templates/navsecond_off.html');
    }
    break;
  }
 }
}

echo '</table>';

?>
This should work

Andreas

ttb
Beiträge: 182
Registriert: So 26. Okt 2003, 19:54
Wohnort: Schwerin
Kontaktdaten:

Beitrag von ttb » Mi 26. Nov 2003, 11:33

Thank you very much! Now it works correctly. :) I think you should add it to the module-section at contenido.de. ;)

mikamedia
Beiträge: 26
Registriert: Mo 30. Jun 2003, 11:07
Kontaktdaten:

Beitrag von mikamedia » Do 27. Nov 2003, 12:07

Thank you very much Andreas!!!

This works great!

Thanks again!

~john

virtualize
Beiträge: 4
Registriert: Di 9. Dez 2003, 12:59
Kontaktdaten:

Beitrag von virtualize » Di 9. Dez 2003, 13:05

i followed your instructions and it worked out well. thanks a lot.

but now there's one problem left.
as i noticed, the script doesn't check for external redirects etc.
so what do i have to do, if i want a link to open a new page in a _blank window?
thanks for taking trouble.

virtualize
Beiträge: 4
Registriert: Di 9. Dez 2003, 12:59
Kontaktdaten:

Beitrag von virtualize » Mi 17. Dez 2003, 15:52

hi, is there anyone, who can help me on the topic descibed above. please?
thanks.

agon
Beiträge: 83
Registriert: Mi 29. Okt 2003, 16:01
Kontaktdaten:

Beitrag von agon » Do 18. Dez 2003, 10:17

Hi,

try this (not tested!):

1. Replace the second SQL-statement by

Code: Alles auswählen

$sql = "SELECT CATTREE.idcat, CATTREE.level, CATLANG.name, ARTLANG.redirect
FROM ".$cfg["tab"]["cat_tree"]." AS CATTREE, ".$cfg["tab"]["cat"]." AS CAT, ".$cfg["tab"]["cat_lang"]." AS CATLANG,
  ".$cfg["tab"]["cat_art"]." AS CATART, ".$cfg["tab"]["art_lang"]." AS ARTLANG
WHERE CATTREE.idcat=CAT.idcat AND CAT.idcat=CATLANG.idcat AND CATLANG.idlang='$lang' AND CAT.idclient='$client'
  AND CATTREE.idcat=CATART.idcat AND CATART.idart=ARTLANG.idart AND CATART.is_start='1'
  AND CATLANG.visible=1 AND (CATTREE.level='1' OR CATTREE.level='2')
ORDER BY CATTREE.idtree";
2. Place this between $tpl->reset(); and $tpl->next();

Code: Alles auswählen

  if($db->f("redirect")=='1')
  {
   $tpl->set('d', 'TARGET', '_blank');
  }
So, when the starting article of a category has an external redirect the link should open in a new window.

I'm not sure but this should work
Andreas

virtualize
Beiträge: 4
Registriert: Di 9. Dez 2003, 12:59
Kontaktdaten:

Beitrag von virtualize » Do 18. Dez 2003, 13:25

thanks.
but doesn't work out.

i checked a bit and as i know the problem is the

Code: Alles auswählen

  $tpl->set('d', 'TARGET', '_blank'); 
statement.
nothing is inserted. i tried several other attributes like title etc.
but the "a href" tag always remains the same.
only NAME and HREF are reflecting a change.

is there some class- / inc- / whatever-phpfile, where i can find the definition
what can be changed / inserted? so i can alter some files by hand.

thanks for taking trouble.

agon
Beiträge: 83
Registriert: Mi 29. Okt 2003, 16:01
Kontaktdaten:

Beitrag von agon » Do 18. Dez 2003, 14:20

Hi,

there should be a subfolder named 'Templates' in your filesystem (e.g. if you are using the standard-client 'cms', this folder has a subfolder named 'Templates'). In this folder, there should be some files nav*_on.html resp nav*_off.html. These files are used to create the links of the navigation-module. In the <a>-tag of these files, there must be target="{TARGET}" to be able to create links that open in a new window.
I tested this Output and it seemed to work (as I have no external redirect in a starting article of a categorie I couldn't test this, but when I changed the code so that every category with a starting article that has no external redirect should open in a new window it worked):

Code: Alles auswählen

<?php

function catIsChildOf($id, $idparent) {
    global $cfg, $client, $lang;

    $db = new DB_Contenido;
    $parent = $id;
    while ( $parent != 0 ) {
        $sql = "SELECT a.parentid
                FROM ".$cfg["tab"]["cat"]." AS a, ".$cfg["tab"]["cat_lang"]." AS b
                WHERE a.idclient='".$client."' AND b.idlang='".$lang."' AND a.idcat=b.idcat AND a.idcat='".$parent."'";
        $db->query($sql);
        $db->next_record();
        $parent = $db->f("parentid");
        if ($parent == $idparent) {
            return true;
        }
    }
    return false;
}

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

// template klasse includen
include_once($cfg["path"]["contenido"] . 'classes/class.template.php');

// template instanz
$tpl = new Template;

$sql = "SELECT CATTREE.idcat, CATTREE.level, CATLANG.name, ARTLANG.redirect
FROM ".$cfg["tab"]["cat_tree"]." AS CATTREE, ".$cfg["tab"]["cat"]." AS CAT, ".$cfg["tab"]["cat_lang"]." AS CATLANG,
  ".$cfg["tab"]["cat_art"]." AS CATART, ".$cfg["tab"]["art_lang"]." AS ARTLANG
WHERE CATTREE.idcat=CAT.idcat AND CAT.idcat=CATLANG.idcat AND CATLANG.idlang='$lang' AND CAT.idclient='$client'
  AND CATTREE.idcat=CATART.idcat AND CATART.idart=ARTLANG.idart AND CATART.is_start='1'
  AND CATLANG.visible=1 AND (CATTREE.level='1' OR CATTREE.level='2')
ORDER BY CATTREE.idtree";

$db->query($sql);

while ( $db->next_record() )
{
if ( catIsChildOf($db->f("idcat"), CMS_VALUE[0]) )
{
  $tpl->reset();
  $tpl->set('d', 'NAME',  $db->f("name"));
if($db->f("redirect")=='1')
  {
   $tpl->set('d', 'TARGET', '_blank');
  }  $tpl->set('d', 'HREF',  $sess->url('front_content.php?idcat='.$db->f("idcat").'&client='.$client.'&la'.'ng='.$lang));
  $tpl->next();
  switch ($db->f("level"))
  {
   case 1:
    if ($idcat == $db->f("idcat"))
    {
     $tpl->generate('templates/navfirst_on.html');
    } else {
     $tpl->generate('templates/navfirst_off.html');
    }
    break;
   case 2:
    if ($idcat == $db->f("idcat"))
    {
     $tpl->generate('templates/navsecond_on.html');
    } else {
     $tpl->generate('templates/navsecond_off.html');
    }
    break;
  }
}
}

echo '</table>';
?>
Hope that might help
Andreas

virtualize
Beiträge: 4
Registriert: Di 9. Dez 2003, 12:59
Kontaktdaten:

Beitrag von virtualize » Fr 19. Dez 2003, 14:48

YEP!
altering the nav*_on.html resp nav*_off.html was the final hint.
sometimes it's that easy. Grrrrrr. :-)

thanks a lot!
bye, Christopher

Gesperrt