Skip to content
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

[4.x] Field based redirects may provide a status #9417

Merged

Conversation

ryanmitchell
Copy link
Contributor

This PR adds the ability to choose whether a redirect from the 'Link' blueprint is a 301 or a 302 redirect.

Closes statamic/ideas#1118

Copy link
Member

@jasonvarga jasonvarga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I started tweaking the code and then we talked about it a little here and came up with some more changes.

Could you please:

  • Remove the redirect_status field.
  • Make redirect into a group field containing url and status fields. (We preferred if there was still just a single field)
  • Make the url sub-field 100% wide
  • Make the status sub-field a 100% width radio with inline: true (The select was a bit cramped)
  • Tweak DataResponse@getRedirect so that:
    • If the value is an array (via the group fieldtype), it gets the url and status from the sub-values.
    • If the value is a string, it uses that like it always has. Assume a 302 status.

@ryanmitchell
Copy link
Contributor Author

No problem. I’ll work on it tomorrow 👍

@ryanmitchell
Copy link
Contributor Author

@jasonvarga thats done. You'll see there were a few other tweaks required to queries and elsewhere in ResolveRedirect

@ryanmitchell ryanmitchell changed the title [4.x] Add redirect_http_status to link blueprint [4.x] Add status option to link blueprint Jan 31, 2024
@jasonvarga
Copy link
Member

Awesome. Thank you.

@wch-karol
Copy link

Wow, thanks @ryanmitchell for looking into my idea :)

@jasonvarga jasonvarga self-assigned this Feb 28, 2024
@jasonvarga jasonvarga changed the title [4.x] Add status option to link blueprint [4.x] Field based redirects may provide a status Mar 11, 2024
@jasonvarga jasonvarga merged commit 963278a into statamic:4.x Mar 11, 2024
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Entry link with configurable redirect status code 302 or 301
4 participants