drewroberts / blog

📝 Laravel package for my opinionated style of adding blog posts to Laravel projects
MIT License
2 stars 4 forks source link

Parent Page Redirect #80

Open drewroberts opened 3 years ago

drewroberts commented 3 years ago

There should be an option with Pages (#15) that allows a Page to redirect & route visitors through the Controller to the parent Page.

An example of a use case for this is with Pages that are created for Locations (https://github.com/tipoff/locations/issues/42) where there is only 1 Location in a Market (https://github.com/tipoff/locations/issues/41). In that case, I want to redirect the visitor to the parent Page (the Market page).

drewroberts commented 3 years ago

If the parent redirect is enabled on a page (I'm thinking a boolean in the database, but whatever is best) and the page does not have a parent, then it should redirect to the website's homepage.

pdbreen commented 3 years ago

If the parent redirect is enabled on a page (I'm thinking a boolean in the database, but whatever is best) and the page does not have a parent, then it should redirect to the website's homepage.

I used the existing location_based flag to trigger the redirects / path building, so the redirect to the home page gets triggered on a location based root page IF and only IF it is the ONLY location based root page.

edit: changing the name also won't change this logic. The locations package will always be setting the flag true for location and market, so honoring the flag becomes conditional on whether its the only root page with the flag set or its the only child.