Jump to content

Trying to rewrite URL's of 3rd child to be under root


Chris FP
 Share

Recommended Posts

Hi all, new to the forum and to ProcessWire. I've been spending some time looking into documentation and the available forum questions previously posted 

but I cannot seem to get it to work. I suspect it's probably a combination of the template not living off the root and that the child is 2 levels down.

Below is code I've added to _init.php

wire()->addHookBefore('Page::path', function($event) {
  $page = $event->object;
  if($page->template == 'portfolio-single-page') {
    // ensure that pages with template 'post' live off the root rather than '/posts/'
    $event->replace = true;
    $event->return = "/$page->name/";
  }
});

The structure of my page is as follows

FULL PAGE URL - /our-projects/video-commercials/aerial-photography-videography/

/our-projects/ - portfolio-page.php

/our-projects/video-commercials/ - portfolio-category-page.php

/our-projects/video-commercials/aerial-photography-videography/ - portfolio-single-page.php

 

Right now I want to simply remove the parents from the child url and have /our-projects/video-commercials/aerial-photography-videography/ go to /aerial-photography-videography/ (unique)

Is this possible?

Link to comment
Share on other sites

hi,

even if i must say i find this a curious idea which sounds so much like a wordpress idea it hurts ? you'll find the working answer in deltavik post in the last thread you quote

more, as a visitor, i really prefer a clear url that makes me know where i am in the website structure and avoids the need of breadcrumbs disfiguring the pages ?

pw not being wp you don't have to avoid default structure url as post, portfolio and so on, you can name your pages the way you want giving your visitors a good idea of what and where they are strolling in, a better UX than a simple domain with everything not organized following (not to speak about SEO...)

have a nice day

 

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...