Jump to content

Remove link from specific top-level page with child pages


Neo
 Share

Recommended Posts

I am having the following simple site-structure and use the Markup Simple Navigation module for the menu, which works without problems:

HOME 

     - Page A

     - Page B

     - Page C

          - child c1

          - child c2

          - child c3

     - Page D

Now, as I don't want to provide an overview page / list view under Page C to display the different child pages,

I am searching for a way to remove the link of Page C from the menu. At the moment it still contains the link, which leads to the template specified for Page C.

How can I remove this specific link without affecting other top-level pages with children (for which I might need the overview)?

Link to comment
Share on other sites

It's a simple list element:

<li class="has_children">
<a href="/processwire/page-c/">Page C</a>
   <ul style="visibility: visible; display: none;">
      <li><a href="/processwire/page-c/child-c1/">Child C1</a></li>
      <li><a href="/processwire/page-c/child-c2/">Child C2</a></li>
      <li><a href="/processwire/page-c/child-c3/">Child C3</a></li>
   </ul>
</li>
Link to comment
Share on other sites

not really, your markup shows a full link to page c:

<a href="/processwire/page-c/">Page C</a>

So you need a hash there instead of the url? will you menu work if the anchor tag is removed entirely? you should test the hardcode first maybe

Link to comment
Share on other sites

i'm not sure if this would work, but you could try adding a url override field to the template and then do this:

'item_tpl' => '<a href="{urloverride|url}">{title}</a>',

haven't tested, but if this doesn't work, it surely would be a good thing for MSN to support...

Link to comment
Share on other sites

Unfortunately, this did not work.

A simple alternative could be to redirect to the first child within the template of the parent as suggested here:

https://processwire.com/talk/topic/15-how-do-i-create-a-page-that-redirects-to-its-first-child/?p=25 

<?php 

if($page->numChildren) $session->redirect($page->child()->url);

This, however, has the downside of a 301-redirection from a SEO perspective.

Isn't there a recommended solution how to deal with such a situation?

I am sure that is a common situation that users don't want to display a specific list view for a parent page. 

Link to comment
Share on other sites

just tested my method and works perfectly. you sure you did it right?

glad i know this works now, gonna come in handy!

1.) Create new field, call it url_override

2.) Add to your template

3.) on the Page C page, type a # into the field

4.) in your treemenu options make sure you have this:

'item_tpl' => '<a href="{url_override|url}">{title}</a>',
  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...