I've long been a fan of something I first encountered in Textpattern, the ability to visit
and always simply see the page about cooking leeks. Effectively the URL beyond /29/ is getting ignored. For example this allows one to use example.com/cooking/29/ as a short, permanent link to a page while retaining the full URL for normal use (and healthy SEO).
Now Twitter self-shortens links <- insert debate if that's good here ->
what I am trying to do is perhaps less important, but I like the idea of being able to refer to a page with an alternate, ultra-short, permanent URL.
To that end I used the code examples here (thank
you) and came up with this:
if($page->id == 1232) // the id of a utility page with the URL /p/
$pageId = $sanitizer->selectorValue($input->urlSegment1);
$redirect = $pages->get('id='.$pageId)->url;
The ->viewable() test is not really working, but that aside I can visit:
and get instantly directed to the page with ID 1190 at it's normal, full URL. Useful
The problem is the viewable
test. If someone tries to visit a page ID for a page not normally visible they are directed to Login, not ideal.
If anyone sees a neat way I can identify all pages that are suitable for display (e.g. the output of the navigation) and use that as a filter to test against so if the ID is not one of those pages I can 404, I'd be most grateful for ideas.