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
Improve handling of pages with tl_page.requireItem
#3540
Improve handling of pages with tl_page.requireItem
#3540
Conversation
There is still one case unhandled: If a page with In my opinion, there is no need to explicitly skip pages with However, maybe the option / checkbox |
Related: #3605 |
Thanks for the update @fritzmg! This pull request fixes the handling of pages with Your pull request will improve the handling of unroutable pages like error pages, which could also end up in a breadcrumbs trail. Can we get this fix merged for Contao 4.12 so the adjustments from @fritzmg may be used to also improve the breadcrumbs for Contao 4.13? |
@SeverinGloeckle @aschempp How do we proceed here? |
eb97d95
to
a004075
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have rebased the PR and I think this can finally be merged. Two things are changed:
- the breadcrumb menu no longer shows pages if no URL can be generated
- pages with
requireItem
no longer have a preview link. The icon in the page list is no longer clickable. If the page URL (...preview?page=17
) is called, it now redirects to the home page (fallback for any "unknown" preview link) instead of throwing an exception.
Thank you @SeverinGloeckle. |
With the new routing, trying to generate a URL for a page with
tl_page.requireItem=1
throws aRouteParametersException
. This pull request prevents or improves the handling of this exception in breadcrumbs and navigation modules as well as in the frontend preview.Improved cases:
1. Breadcrumbs, current item has
requireItem
Generate the URL from the current request instead of re-generating it from the taget page.
Note: The URL is generated via
strtok(Environment::get('request'), '?')
so any query string is not added to the breadcrumbs URL.2. Breadcrumbs, item in parent trail has
requireItem
Skip pages with
tl_page.requireItem=1
in the parent trail of the breadcrumbs, even ifshowHidden
is enabled.Note: These pages are skipped explicitly in the breadcrumbs (and not handled by the future proof fix below) to prevent spamming the log with error messages for failed URL generations.
3. Future proof breadcrumbs
Only add items with a non-empty URL (
$href
) to the breadcrumbs (except root page).This way, if some page types will not generate a proper URL (after an exception or for pages with no public route in the future), they will neither get added to the breadcrumbs nor to the JSON-LD data.
4. Frontend preview
If a
RouteParametersException
is thrown for a page when converting the frontend preview URL and the reason for the exception is anInvalidParameterException
on a page withtl_page.requireItem
, catch the exception and do not set a URL for the preview, thus starting the preview on the root page.