Sign in to follow this  
Neo

Remove link from specific top-level page with child pages

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)?

Share this post


Link to post
Share on other sites

it depends on how Page C menu item is supposed to behave - is it just a list element, a hash, or a javascript:void(0) ?

Share this post


Link to post
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>

Share this post


Link to post
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

Share this post


Link to post
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...

Share this post


Link to post
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. 

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Sorry, now I got it. You're right; it works.

An additional redirect in the template might make sense for the case that the page-link is accessed directly.

Share this post


Link to post
Share on other sites

yes, definitely because someone might backhack to that page

Share this post


Link to post
Share on other sites
On 6/6/2015 at 4:22 AM, Macrura said:

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>',

Hi @Macrura just two little questions:

1.) The new field which is to create which type of field do I have to choose?

3.) # would be a dead link but I will work with any website url ... ?

Share this post


Link to post
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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.