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

[FR] When changing a slug of an entry in a structure, add redirects for childs #23

Open
riasvdv opened this issue Oct 2, 2018 · 11 comments
Labels
enhancement New feature or request

Comments

@riasvdv
Copy link

riasvdv commented Oct 2, 2018

So when changing an entry's slug, a redirect is created for the entry, but if it has childs that depend on the slug for their own urls, they don't have a redirect.

@khalwat
Copy link
Contributor

khalwat commented Oct 3, 2018

As in for a structure?

@khalwat khalwat added the need info Need more information on the issue label Oct 3, 2018
@riasvdv
Copy link
Author

riasvdv commented Oct 4, 2018

Yeah!

@SanderVanLeeuwen
Copy link

This is something I'm running in to as well. We have a structure for pages which are accessed by slug; for example:

/sample-page
/sample-page/and-a-child

Changing /sample-page to /sample-page-changed doesn't update the second page to /sample-page-changed/and-a-child. I realise that supporting this means adding a rewrite for every page in the, theoretically, infinite depth page tree, but it would ensure that pages are always properly redirected.

@khalwat khalwat added enhancement New feature or request and removed need info Need more information on the issue labels Feb 4, 2019
@ademers
Copy link

ademers commented Jan 19, 2021

I have a similar request. I'd like Retour to automatically create a redirect when changing an entry's level in a Structure.

For example, when I drag and drop an entry from level 1 to level 3, the entry is redirected as follows:

/section/entry-slug --> /section/level1/level2/entry-slug

Screenshot of real-life example:
CleanShot 2021-01-19 at 11 40 03

Thanks for you consideration! 🙏

@khalwat
Copy link
Contributor

khalwat commented Jan 20, 2021

Yeah these two are essentially the same thing. I agree it'd be a good feature to add

@development-lameco
Copy link

Any update on this? This would be an essential feature for multi level structure pages.
Also I am wondering if the redirect of a parent doesn't do this automatically if you would use regEx logic in the Legacy URL Pattern.

Because if you would make such a redirect in .htaccess the order of the redirects is important for URLs beginning with the same pattern.

@khalwat
Copy link
Contributor

khalwat commented Mar 31, 2022

@development-lameco The feature hasn't been added yet, but good to hear you are interested

@khalwat
Copy link
Contributor

khalwat commented Apr 6, 2022

So I've actually put a good bit of thought into this, over quite a bit of time.

Here's the thing... we're thinking about this from the perspective that in a structure, there's a hierarchy, and it makes sense to us that the URL might be built based on their hierarchy.

However, the way the URL rules are done, it's completely free-form. You could write URLs that have the parent URL in the last segment, or depend on things in arbitrarily unusual ways.

So we can't just "update all the children's URLs" because we have no idea if your URL format actually affects things in that manner.

The same with changing the level of a structure; in the default setup, that changes nothing in terms of the URL. In some custom setups, it might change the URL, but exactly how is up to you, and how you wrote it.

So I'm left with not really having a clear idea how I could implement this feature in a way that would work universally. I could write it such that it'd work if people did common things that made sense (like parent-child relationships with items in the structure), but it wouldn't cover it all.

@ademers
Copy link

ademers commented Apr 6, 2022

I could write it such that it'd work if people did common things that made sense (like parent-child relationships with items in the structure), but it wouldn't cover it all.

That would work for me, and, as you mentioned, probably the most common way that people use Structure Section types. In other words: entry uRLs reflect the Structure hierarchy.

@khalwat
Copy link
Contributor

khalwat commented Apr 6, 2022

Well, what I'm trying to express is that I'm reluctant to come up with an implementation that makes assumptions, and is not universal.

The only way I can see this always working for everything is if I either:

  • Find an event that is triggered when URLs are rewritten as a result of something else in the structure changing
  • Scan all of the entries in a structure whenever any entry changes, looking for URL pattern changes

@development-lameco
Copy link

Here's the thing... we're thinking about this from the perspective that in a structure, there's a hierarchy, and it makes sense to us that the URL might be built based on their hierarchy.
However, the way the URL rules are done, it's completely free-form. You could write URLs that have the parent URL in the last segment, or depend on things in arbitrarily unusual ways.

You are right, didn't think about that.
Of course the most common as you said for a structure is parent/child url, but you never know what crazy stuff people and clients come up with. (could imagine any other logical structure).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants