Results 1 to 7 of 7

Thread: Non Linked Menu Item

  1. #1
    New user
    Join Date
    07-01-10.
    Location
    Midlands, UK
    Posts
    26

    Default Non Linked Menu Item

    Hi

    I would like to create an entry in the navigation menu that isn't a link so that it serves only as a heading to a drop down. So is there a waty to detect if an item has subitems and if so not create a link. The example is here: http://www.renewablesfirst.co.uk - we want the 'Hydro Services' and 'Wind Services' to have the drop down but not be links themselves.

    Any thoughts on this would be greatly appreciated.

    Thank you

  2. #2
    Experienced user
    Join Date
    06-20-09.
    Posts
    1,311

    Default Re: Non Linked Menu Item

    You could make the page "Wind Services" an internal redirect to "Intro to Wind services" in Site Structure perhaps?

  3. #3
    imported_Nina
    Gast

    Default Re: Non Linked Menu Item

    @redwax: Please check "language default" in the page root. You forgot it and that is the reason why I can't even take a look at your page but only get the dreadfull "No pages found"-message

  4. #4
    Community-Moderator xchs's Avatar
    Join Date
    06-19-09.
    Posts
    1,287

    Default Re: Non Linked Menu Item

    Hi redwax,
    Quote Originally Posted by redwax
    I would like to create an entry in the navigation menu that isn't a link so that it serves only as a heading to a drop down.
    You can change your default navigation template "nav_default.tpl" as follows:

    Code:
    <ul class="<?php echo $this->level; ?>">
    <?php foreach ($this->items as $item): ?>
    <?php if ($item['isActive']): ?>
    <li class="active<?php if ($item['class']): ?> <?php echo $item['class']; ?><?php endif; ?>"><span class="active<?php if ($item['class']): ?> <?php echo $item['class']; ?><?php endif; ?>"><?php echo $item['link']; ?></span><?php echo $item['subitems']; ?>
    <?php else: ?>
    <li<?php if ($item['class']): ?> class="<?php echo $item['class']; ?>"<?php endif; ?>><?php if(strpos($item['class'], 'nonavlink')===false):?> "<?php if ($item['class']): ?> class="<?php echo $item['class']; ?>"<?php endif; ?><?php if ($item['accesskey'] != ''): ?> accesskey="<?php echo $item['accesskey']; ?>"<?php endif; ?><?php if ($item['tabindex']): ?> tabindex="<?php echo $item['tabindex']; ?>"<?php endif; ?><?php if ($item['nofollow']): ?> rel="nofollow"<?php endif; ?><?php echo $item['target']; ?>><?php else: ?><span class="<?php echo $item['class']; ?>"><?php endif; ?><?php echo $item['link']; ?><?php if(strpos($item['class'], 'nonavlink')===false):?><?php else: ?></span><?php endif; ?><?php echo $item['subitems']; ?>
    <?php endif; ?>
    <?php endforeach; ?>[/list]
    After renaming the template to e.g. "nav_partiallinked.tpl" you con choose it in your navigation frontend module.

    Finally, assign to all pages in your site structure, which should not be linked in the navigation menu, the CSS class "nonavlink".

    HTH
    Contao Community Moderator
    → Support options

  5. #5
    New user
    Join Date
    07-01-10.
    Location
    Midlands, UK
    Posts
    26

    Default Re: Non Linked Menu Item

    Quote Originally Posted by Nina
    @redwax: Please check "language default" in the page root. You forgot it and that is the reason why I can't even take a look at your page but only get the dreadfull "No pages found"-message
    Thanks for the info - I hadn't clocked this setting.

  6. #6
    New user
    Join Date
    07-01-10.
    Location
    Midlands, UK
    Posts
    26

    Default Re: Non Linked Menu Item

    Quote Originally Posted by xchs
    Hi redwax,
    Quote Originally Posted by redwax
    I would like to create an entry in the navigation menu that isn't a link so that it serves only as a heading to a drop down.
    You can change your default navigation template "nav_default.tpl" as follows:

    Code:
    <ul class="<?php echo $this->level; ?>">
    <?php foreach ($this->items as $item): ?>
    <?php if ($item['isActive']): ?>
    <li class="active<?php if ($item['class']): ?> <?php echo $item['class']; ?><?php endif; ?>"><span class="active<?php if ($item['class']): ?> <?php echo $item['class']; ?><?php endif; ?>"><?php echo $item['link']; ?></span><?php echo $item['subitems']; ?>
    <?php else: ?>
    <li<?php if ($item['class']): ?> class="<?php echo $item['class']; ?>"<?php endif; ?>><?php if(strpos($item['class'], 'nonavlink')===false):?> "<?php if ($item['class']): ?> class="<?php echo $item['class']; ?>"<?php endif; ?><?php if ($item['accesskey'] != ''): ?> accesskey="<?php echo $item['accesskey']; ?>"<?php endif; ?><?php if ($item['tabindex']): ?> tabindex="<?php echo $item['tabindex']; ?>"<?php endif; ?><?php if ($item['nofollow']): ?> rel="nofollow"<?php endif; ?><?php echo $item['target']; ?>><?php else: ?><span class="<?php echo $item['class']; ?>"><?php endif; ?><?php echo $item['link']; ?><?php if(strpos($item['class'], 'nonavlink')===false):?><?php else: ?></span><?php endif; ?><?php echo $item['subitems']; ?>
    <?php endif; ?>
    <?php endforeach; ?>[/list]
    After renaming the template to e.g. "nav_partiallinked.tpl" you con choose it in your navigation frontend module.

    Finally, assign to all pages in your site structure, which should not be linked in the navigation menu, the CSS class "nonavlink".

    HTH
    You're a genius. Thanks ever so much this worked a treat!

  7. #7
    Community-Moderator xchs's Avatar
    Join Date
    06-19-09.
    Posts
    1,287

    Default Re: Non Linked Menu Item

    Fine. You're welcome.

    N.B.: The above solution was taken over from the German Contao Wiki.
    Contao Community Moderator
    → Support options

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •