-
Notifications
You must be signed in to change notification settings - Fork 333
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using setURLSuffix on URLSegment field is not respected in SiteTreeURLSegmentField.js correctly #2723
Comments
Removing the urlSuffix in Page.php by setting it to false works in source, but javascript adds it again. Resulting in link with undefined at the end. **Setting URLSuffix to false, if page is published:** ``` public function getCMSFields() { $fields = parent::getCMSFields(); if( $this->isPublished() ) { $fields->FieldByName('Root.Main.URLSegment')->setURLSuffix(false); } } ``` See issue: silverstripe#2723 silverstripe#2723
Do you want to open a pull request, @RVXD? |
Sorry, we can't really do this. The ?stage=Stage query string is used to ensure that HTTP caching is disabled. Also at once point ?stage=Stage wasn't always used and instead sessions were used to say which stage you were on. However this was changed to always using the ?stage=Stage to resolve a class of bug of which I can't exactly remember |
I still think the change to SiteTreeURLSegmentField.js could and should be made without having a negative impact on the functionality. A lot of users think this is the URL they can communicate to the world. The ?stage=Stage part does not have to be removed at all from the preview pane or anywhere else. Just from the segment field, so that if someone copies it, it is not in there. |
Yeah, I think if @emteknetnz takes a second look and reads through the issue again, it is really only about fixing the JS to correctly respect the already existing settings, nothing else. It's not intended to remove the query param. |
Alternatively, if we want to ensure |
This change won't affect the default behaviour, but makes extending or changing the behaviour to suit the needs of a given project easier. Makes sense to me. I'd even go so far as to say that technically not respecting an empty suffix could be considered a bug. |
I came here looking to do as @RVXD wants to, but this bug stops it from being possible to remove Another workaround for the problem @RVXD is trying to stop could be to override <button onclick="navigator.clipboard.writeText('{$URLPrefix}{$Value}')" role="button" type="button" class="btn btn-outline-secondary btn-sm font-icon-clipboard-pencil">Copy</button> |
I'd like to be able to remove the ?stage=Stage link from the URLSegment field in the CMS. Some clients keep copying this link into their newsletters/socialmedia messages. If people click on it these links they need to login. For most non-technical users this is confusing.
Removing the urlSuffix in Page.php by setting it to false works in source, but javascript adds it again. Resulting in link with undefined at the end.
Setting URLSuffix to false, if page is published:
Workaround setting URLSuffix to '?', if page is published:
Now all the links will end with a '?'
Current SiteTreeURLSegmentField.js
Always adds suffix. If it is empty or false causing 'undefined' in the URL.
Proposed change to SiteTreeURLSegmentField.js:
Only add suffix if it not false.
The text was updated successfully, but these errors were encountered: