1

Topic: Unclickable Menu?

Hello,

I have a menu, I am using the suckerfish : http://wolfcms.office-web.net/extension … ulant.html

The website I am creating has several drop down childes coming out of the parents.

The question is,
I want the Childes to be clickable (links)
I dont want the Parents to be clickable ( example: <a href="#"> )

Help?

Last edited by tamz (2010-05-17 23:39)

2

Re: Unclickable Menu?

Hi tamz - you could try this (warning! untested) for the "PHP function":

<?php
function displayChildren($page, $current, $startmenu = true, $limits = null) {
    if ($limits != null && array_key_exists($page->slug, $limits)) {
        $arr = array('order' => 'position ASC, published_on DESC', 'limit' => $limits[$page->slug]);
    } else
        $arr = array('order' => 'position ASC, published_on DESC');
    if ($page && count($page->children()) > 0) {
        echo ($startmenu) ? '<ul>' : '';
        foreach($page->children($arr) as $menu) :
        $daddy = (count($menu->children()) > 0 &&  $menu->level() > 1) ? ' class="daddy"' : null;
        $link = (count($menu->children()) > 0 &&  $menu->level() > 1) ? '#' : $menu->url();
            echo '<li><a href="'. $link .'"'.  $daddy .'>'. $menu->title() .'</a>';
                displayChildren($menu, $current, true, $limits);
                echo '</li>';
            endforeach;
        echo ($startmenu) ? '</ul>' : '';
    }
}
?>

Basically, it adds a test like the "$daddy" one which adds the class for the drop-down, but now adds a "$link" variable which will return a clickable URL if it is NOT a parent, but just "#" if it IS a parent.

Let us know if it works! (We live in hope...)

3

Re: Unclickable Menu?

this didnt work ..
sad

4

Re: Unclickable Menu?

This code works for me. I'm using it with superfish menu.

<?php
function displayChildren($page, $current, $startmenu = true, $limits = null) {
  if ($limits != null && array_key_exists($page->slug, $limits)) {
    $arr = array('order' => 'position ASC, published_on DESC', 'limit' => $limits[$page->slug]);
  } else
    $arr = array('order' => 'position ASC, published_on DESC');
  if ($page && count($page->children()) > 0) {
    echo ($startmenu) ? "\n".'<ul>'."\n" : ''."\n";
    foreach($page->children($arr) as $menu) :
        echo '<li'.(in_array($menu->slug, explode('/', $current->url)) ? ' class="active"': null).'>';
        if ($menu->childrenCount() > 0) {
          echo '<a>'.$menu->title.'</a>';
        }
        else {
          echo $menu->link($menu->title);
        }
        displayChildren($menu, $current, true, $limits);
        echo '</li>'."\n";
    endforeach;
    echo ($startmenu) ? '</ul>' : ''."\n";
  }
}
?>

and then call the function:

<?php
$page = $this->find('/');
echo displayChildren($page, $this, false, array('articles' => '0', 'a-sub-page' => '1'));
?>
</ul>

Thumbs up

5

Re: Unclickable Menu?

Thanks xkapr !

this works great,
Just one problem .. the link to the Homepage, dissapeared!

6

Re: Unclickable Menu?

Nevermind, I got it to work !

Thanks dude!