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

[5.x] Add filters from collection/taxonomy list to breadcrumb back link #11243

Conversation

florianbrinkmann
Copy link
Contributor

I got the request from a client if it’s possible to change the link that points back to the collection list from the edit view, so that it includes search/filter/sort params that were set before the user entered the single view from the list. I found a corresponding feature request in statamic/ideas statamic/ideas#1049, and this PR aims to add that functionality that can be enabled via a config key.

I’m not sure if that is the best place for the config key (and if the name is clear enough), and if it’s a good idea to extend the Breadcrumbs class, but I couldn’t fint another place where the method could go. Thought about adding a Trait, but left it this way for now.

@jasonvarga
Copy link
Member

Do you have a specific reason that you made it opt-in with a config? I don't really see a reason someone wouldn't want it.

@florianbrinkmann
Copy link
Contributor Author

No specific reason @jasonvarga, I just didn’t want to change a default behavior, that’s all :)

I don't really see a reason someone wouldn't want it.

Yes, you’re right, me neither. Should I remove the opt-in?

@jasonvarga
Copy link
Member

I appreciate that 😄 Yeah, let's remove the opt-in.

@florianbrinkmann
Copy link
Contributor Author

Removed the opt-in and made a change to also add the page param

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.

Could you please give me permission to push to your branch? Usually it would auto-close the PR if your branch doesn't give us permission. Weird. 🤔

Or, please make the following change yourself:

  • Remove additions to Breadcrumbs.php
  • Change the breadcrumbUrl methods to the following.
    public function breadcrumbUrl()
    {
        $referer = request()->header('referer');
        $showUrl = $this->showUrl();

        return $referer && Str::before($referer, '?') === $showUrl ? $referer : $showUrl;
    }

This would just check that the refererer is the showUrl. If it is, use all the query parameters as-is.

This seems much simpler, but maybe you can see a reason for needing to do what you originally did.

@florianbrinkmann
Copy link
Contributor Author

That‘s really weird, the checkbox is active, and I had a PR first where it wasn’t allowed which was auto-closed (because I made it from an organization account).

Bildschirmfoto 2024-12-16 um 18 36 38

Your changes look a lot better than my check-escalation indeed, I’ll give it a try tomorrow and apply the changes :)

@florianbrinkmann
Copy link
Contributor Author

@jasonvarga I made the changes

@jasonvarga jasonvarga merged commit bccb3a0 into statamic:5.x Dec 17, 2024
18 checks passed
@jasonvarga jasonvarga changed the title [5.x] Add option to add filters from collection/taxonomy list to breadcrumb »back« link in single view [5.x] Add filters from collection/taxonomy list to breadcrumb back link Dec 17, 2024
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.

2 participants