DrQuincy Posted December 16, 2021 Share Posted December 16, 2021 I'm not sure if I'm missing something glaringly obvious here but if you set URLs (not segments) to not have trailing slashes you will still get one at the end when accessing $page->path. So $page->path for my sitemap.xml file is /sitemap.xml/. Yes if you visit /sitemap.xml/ it redirects to /sitemap.xml — but why doesn't it just return /sitemap.xml? This will end up adding an awful lot of unnecessary requests. Is this intended behaviour? I have also noticed the API only seems to work with forward slashes too (e.g. parent=/foo/bar/, not parent=/foo/bar) — but I get that as a design decision since the the trailing slash setting is effectively abstract from that. Link to comment Share on other sites More sharing options...
Robin S Posted December 16, 2021 Share Posted December 16, 2021 The trailing slash setting is something that applies to URLs rather than paths, i.e. $page->url rather than $page->path. Related GitHub issue with response from Ryan: https://github.com/processwire/processwire-issues/issues/273 2 Link to comment Share on other sites More sharing options...
DrQuincy Posted December 17, 2021 Author Share Posted December 17, 2021 Ah, thanks, yes, that explains it. I always assumed $page->url was the full URL but that is actually httpUrl; var_dump(wire('pages')->get('/sitemap.xml/')->path); // "/sitemap.xml/" var_dump(wire('pages')->get('/sitemap.xml/')->url); // "/sitemap.xml" var_dump(wire('pages')->get('/sitemap.xml/')->httpUrl); // "http://site.local/sitemap.xml" Thanks, I will use ->url in future. ? Link to comment Share on other sites More sharing options...
Clarity Posted December 20, 2021 Share Posted December 20, 2021 Hello, @DrQuincy! I've noticed that you've used var_dump() for dumping variables. You can use TracyDebugger instead. It will allow you to work much faster: . 1 Link to comment Share on other sites More sharing options...
DrQuincy Posted December 20, 2021 Author Share Posted December 20, 2021 Thanks for the tip. ? 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