IkBenBen Posted October 30, 2016 Share Posted October 30, 2016 Hi all, I know this has been asked and answered multiple times... but I'm still having a hard time understanding this so forgive me for asking. In two parts of my website I would like to ignore the parent page and change the URL structure from: /services/list/page to /services/page and /articles/list/article to /articles/article How do I accomplish this? I'm sure the solution must be really simple. But for me being a beginner PHP coder, I just can't seem to get my head around it. Thanks in advance! Link to comment Share on other sites More sharing options...
kongondo Posted October 30, 2016 Share Posted October 30, 2016 (edited) Have a read here: (scroll down a bit if you want to do it via Hooks) Edited October 30, 2016 by kongondo clarity... 1 Link to comment Share on other sites More sharing options...
IkBenBen Posted October 30, 2016 Author Share Posted October 30, 2016 Thanks for the reply. I tried with the hooks but don't know how to use them (even after reading the documentation). Where do you place the "hook"? Link to comment Share on other sites More sharing options...
kongondo Posted October 30, 2016 Share Posted October 30, 2016 Did u read that whole thread ?...similar questions were asked (where to place) and there were answers there... Link to comment Share on other sites More sharing options...
cjx2240 Posted November 29, 2016 Share Posted November 29, 2016 Sorry to bump this thread but its quite related and the thread not too old. If you have some pages in your site that are just in the footer, like Terms & Conditions and Help, where do you tend to put the pages in your processwire? For me, it makes sense to have a page called Footer, and make any menu items that will be in the footer be sub-pages of that. Then, I can build a menu from pages with parent=footer. However, if I do this, my urls will include their parent, eg /footer/help - obviously this is not desirable. I guess I can call footer whatever I want, like /other/help, or /information/help, but the point is more that I don't want the parent to dictate the URL for something that I want to consider a "top level" page (despite its physical location). I get that there are solutions to fix this in code, but I feel like this is something that should be managed in the CMS. And if not, in this particular circumstance, how would you suggest allowing the administrator to add to the footer menu? Link to comment Share on other sites More sharing options...
LostKobrakai Posted November 29, 2016 Share Posted November 29, 2016 Just because a page happens to be linked only in the footer it's probably not supposed to be nested in the page tree. ProcessWire does hold pages in a hierarchical structure, which does not necessarily correspond to all the various navigational patterns used throughout the page. I'd just add those pages as "hidden" children of home. Hidden because they're not part of the primary navigation, but the are still direct children of home (think of the breadcrump you'd have for that page). For building the footer menu I'd just hardcode that one in the template or use some of the few menu builder tools available for ProcessWire. 2 Link to comment Share on other sites More sharing options...
cjx2240 Posted November 29, 2016 Share Posted November 29, 2016 Thanks Lost, That may be the answer, that or simply make a template for menu management with a pages selector field, although that would limit my menu so it couldn't include external links... aah... Do you have a particular recommendation for menu builder? Can't find one that appears maintained. Link to comment Share on other sites More sharing options...
kongondo Posted November 29, 2016 Share Posted November 29, 2016 1 hour ago, cjx2240 said: Do you have a particular recommendation for menu builder? Can't find one that appears maintained. Really? There's only 2 and they are both maintained... Welcome to the forums 2 Link to comment Share on other sites More sharing options...
cjx2240 Posted November 29, 2016 Share Posted November 29, 2016 Thanks! sorry if I appear fussy, the top result, Menu Builder, has a 3.x bug, but I found the pull request that had a fix, and now I'm using that. It solves my problem and is a nice method of menu management going forward anyway. I do personally think a URL should be fully rewriteable in the CMS out of the box, but still happy with this solution Edit: just noticed your name from the menu builder I linked, glad I had good things to say! Link to comment Share on other sites More sharing options...
adrianmak Posted November 29, 2016 Share Posted November 29, 2016 Just found this post and learn this technique. I tried to replicate for a test on this technique posts is template posts post is template post I replicated the code from another post in the _init.php file wire()->addHookBefore('Page::path', function($event) { $page = $event->object; if($page->template == 'post') { // ensure that pages with template 'post' live off the root rather than '/posts/' $event->replace = true; $event->return = "/$page->name/"; } }); If everything is all right, i should access that page with urlhttp://test.local.net/pw3/post-1/ (pw3 is a subfolder of www root) it returned 404 page not found. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now