alan Posted April 13, 2012 Share Posted April 13, 2012 A couple of times I've thought "It would be good if I could get from the API directly all of the publicly visible pages and nothing more, or use the API to build an array that I could subsequently look in that held this set". That set of pages would be those we would want, for example, Google to know about and so would not include the login page or pages like example.com/pw/repeaters/for-field-123/for-page-1456/ In pseudo code one way I could see doing it would be: foreach(section-is-part-of-nav) { foreach(page-in-section-is-part-of-nav) { visible-pages-array[store-this-page-id] } } Two uses I can think of are to help when building a sitemap.xml file (I've not yet looked at the sitemap.php template that ships with PW, shame on me if that solves all of this) and the other use is for allowing short-links to work, but only for normal, public pages. Any thoughts on how this can be done will be received with great interest PS: What's the betting this can likely be done directly with the API and I've missed something simple and obvious... Link to comment Share on other sites More sharing options...
diogo Posted April 13, 2012 Share Posted April 13, 2012 There is a sitemap module http://processwire.com/talk/topic/799-module-xml-sitemap/ Doesn't solve the short-links part, but maybe you can figure also this from there. Link to comment Share on other sites More sharing options...
alan Posted April 14, 2012 Author Share Posted April 14, 2012 Thanks diogo, that looks very useful and it may allow me to solve the more general thing I was looking for (find all pages suitable for public consumption). Link to comment Share on other sites More sharing options...
Soma Posted April 14, 2012 Share Posted April 14, 2012 OR use my MarkupSimpleNavigation. Link to comment Share on other sites More sharing options...
alan Posted April 14, 2012 Author Share Posted April 14, 2012 Soma, I totally forgot! WHAT am I like... And I had your module bookmarked from the start and watch the thread too as it's something I am sure I will need. Thanks for the suggestion, I'll check it for use in solving this, cheers! Link to comment Share on other sites More sharing options...
alan Posted April 16, 2012 Author Share Posted April 16, 2012 OK, the solution "I've" come up with (err, Soma and Ryan came up with ) is a hybrid of some of Soma's code and Ryan's: if($page->id == 1232 && $id = (int) $input->urlSegment1) { // 1232 is a page with the URL /p/ $redirect = $pages->get("id=$id"); if($redirect->id && $redirect->viewable()) { $session->redirect($redirect->url); } else { //throw new Wire404Exception(); $session->redirect($pages->get($config->http404PageID)->url); } } This is now complete and solves the short-links referred to in the opening post of this thread. I might see if I can make this into a Module. I don't know if it is a good candidate for being a Module and I don't know if I will be able to work out how to do it and I don't know when I'll get to try (just a few don't know's then ) but maybe I'll do it! Meantime, thanks again to everyone who commented, cheers, -Alan 1 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