cpx3 Posted March 2, 2022 Share Posted March 2, 2022 Hello! When I try to get an urlSegment of a page that has no urlSegment (i.e. www.domain.com/ ) the value is always changed to "assets". When trying to receive urlSegment2 (that also does not exist) I get the filename of an image. Any idea what I am doing wrong? Thanks in advance, Bernhard Link to comment Share on other sites More sharing options...
wbmnfktr Posted March 2, 2022 Share Posted March 2, 2022 Maybe this helps you:https://processwire.com/docs/front-end/how-to-use-url-segments/ You can always define a default fallback (see: Best practices) whenever something doesn't match. Your fallback to assets sounds weird to me, as it's not a common key I know about. Link to comment Share on other sites More sharing options...
cpx3 Posted March 2, 2022 Author Share Posted March 2, 2022 wbmnfktr, thanks for your answer! Actually I have not a general problem with urlSegments, they work. When using urlSegment1 on www.domain.com/seg1/seg2 it works fine. The problem appears when I save this urlSegment1 to a session and then call a page www.domain.com/ with NO urlSegment, the session value is changed to "assets" even I tell PW to change the session value only if strlen($input->urlSegment1)>0. This only happens when I want PW to leave the session value alone... It must have to do with urlSegments (#3 for example gave me the path of an image file) as the problem does not occur with any other value. Link to comment Share on other sites More sharing options...
wbmnfktr Posted March 3, 2022 Share Posted March 3, 2022 Oh... ok... I never use anything with sessions as they don't work with ProCache (or at least not for me), which is almost always present in my projects. Do you have any caching in place? Maybe that's the reason it doesn't work. But for now... no... sorry. No clue why it doesn't work out in sessions. 1 Link to comment Share on other sites More sharing options...
cpx3 Posted March 3, 2022 Author Share Posted March 3, 2022 Oh, thanks for the hint! How do you replace sessions to work with Procache? (I use that, too) 1 Link to comment Share on other sites More sharing options...
wbmnfktr Posted March 3, 2022 Share Posted March 3, 2022 I don't use them at all. No need at all, after deciding ProCache's benefits have more weight. And... I really never had the need or a real reason to use sessions - besides user/member pages - but in those cases my setup looks different right from the start and even those don't use sessions. In case I need something like that, I most often use cookies or local storage. Still I can count all those scenarios on 5 fingers. What's your setup or goal for your setup/project? Why do you need those sessions? In case for search or a limited part of your sites... think about disabling ProCache for those pages. 1 Link to comment Share on other sites More sharing options...
cpx3 Posted March 3, 2022 Author Share Posted March 3, 2022 I do not use ProCache in this project but in another, so is good to know that it might cause troubles (I never read about that). I need sessions for navigation as I do not want urlSegments on the startpage and I need to know which in which „area“ of the page the user is (the menu depends on that). Any other idea? Link to comment Share on other sites More sharing options...
flydev Posted March 3, 2022 Share Posted March 3, 2022 9 hours ago, cpx3 said: Any other idea? @cpx3 give a read to @MoritzLost's article: https://processwire.dev/performance-optimizations-for-processwire/#server-side-caching-template-cache-and-procache and there https://github.com/MoritzLost/CachePlaceholders - #motivation-and-breakdown 1 2 Link to comment Share on other sites More sharing options...
cpx3 Posted March 3, 2022 Author Share Posted March 3, 2022 @flydev Merci beaucoup (also for your wonderful modul!) Eventually I found the problem: it was a missing trailing slash in the url segment, although the setting was to either / or. Thanks to all of you for the support! 2 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