Problem/Motivation
As discussed with borisson_ yesterday, I think that probably a common use case is to have a FacetSource block + facets and create a new route with Page Manager using parameters. For example /catalog/{tid}
With the current InboundPathProcessor for pretty paths, we only verify that a facet source (page) with the current requested route exists and then we remove the filters to obtain the base path. Here is the code from Drupal\facets_pretty_paths\PathProcessorPrettyPaths
:
// If path starts with an url having a facet source, reroute all subpaths to
// the facet source.
foreach ($facet_sources as $facet_source) {
$facet_source_plugin = $facet_source_plugin_manager->createInstance($facet_source['id']);
$facet_source_path = $facet_source_plugin->getPath();
if ($path && strpos($path, $facet_source_path, 0) === 0) {
$path = $facet_source_path;
}
}
Views would have the same problem AFAIK.
So actually a path like this http://example.com/catalog/856/size/107
generated by our UrlProcessor will give us a 404.
Proposed resolution
I would like to create a standard solution to detect if a page exists and then remove this part correctly using the InboundPathProcessor. My solution is to load all the pages and request for the parameters and the path(per page). Then obtain the path removing the filters.
But I have 3 things in mind:
1) Not sure if it would be very expensive to load all the pages (and Views ??)
2) I need to think in a correct pattern to check the path from page manager pages and detect the parameters and then remove the filters obtaining the correct base path.
3) Well a custom solution is always possible but I would like to contribute a standard solution if possible ;)
Opinions/help are welcome :)
Comment | File | Size | Author |
---|---|---|---|
#10 | 2779971-10.patch | 3.41 KB | marthinal |
#17 | page-manager-and-language-problem-2779971-17-combined.patch | 12.69 KB | piggito |
#17 | interdiff-15-17.txt | 730 bytes | piggito |
#17 | page-manager-and-language-problem-2779971-17.patch | 12.26 KB | piggito |
Comments
Comment #2
marthinal CreditAttribution: marthinal commentedComment #3
StryKaizerNot sure if I understand your solution.
Is it correct that you want to load all page manager pages which contain a facetsource view using facets pretty paths, and collect their paths?
If so, yes, that might work.
we could create a hook or plugin system to provide paths and facetsource combinations to pretty paths which will also trigger the system.
We can probably add some caching to that system, making it much faster, I am planning on adding a caching layer for the paths anyway (as I load every facetsource at the moment every cold request now, there's no reason to do this more then once).
Comment #4
StryKaizerComment #5
marthinal CreditAttribution: marthinal commented@StryKaizer sorry for the delay,
Is it correct that you want to load all page manager pages which contain a facetsource view using facets pretty paths, and collect their paths?
Yes that was the idea but I had no time to continue working on it.
Comment #6
marthinal CreditAttribution: marthinal commentedI added the logic to verify if the current path is a page. We need to test routes with params.
Comment #7
marthinal CreditAttribution: marthinal commentedComment #8
plopescHey There!
Comment #9
marthinal CreditAttribution: marthinal at Bluespark commentedAdded regex to detect the paths with params.
Please give credit to @plopesc. He helped me with the regex. :)
Comment #10
marthinal CreditAttribution: marthinal at Bluespark commentedHere is the patch!
Comment #11
ilya.no CreditAttribution: ilya.no as a volunteer and at Skilld for Skilld commentedThanks for the patch! While I worked with it, I faced with problem, described in this issue. So I had to re-worked the patch to include language fix into it as well. I'm not sure, if I should create new issue, so attaching patch here.
Comment #12
andypostdo not use editable here
Comment #13
ilya.no CreditAttribution: ilya.no as a volunteer and at Skilld for Skilld commentedThanks for the feedback. Attaching new patch.
I also faced following issue: I have search page with path '/search' and node view page with path '/node/{node}'. When I go to node adding page, e.g. '/node/add/article', then I'm redirected to 'node/add', because of getPageManagerPath() and preg_replace() inside it. I'm not sure, if this is common issue and about best way to solve it, so I've added additional if() condition inside 'if (preg_match($pm_path, $path, $matches)) {' and it works for me.
Comment #14
ilya.no CreditAttribution: ilya.no as a volunteer and at Skilld for Skilld commentedUpdated patch with minor fix for comment of the constructor.
Comment #15
ilya.no CreditAttribution: ilya.no as a volunteer and at Skilld for Skilld commentedAdded re-rolled patch against updated code of the module.
Comment #16
piggito CreditAttribution: piggito as a volunteer and at Skilld commentedPatch has collision with #2924492: url_processor Not compatible with latest Facets UrlProcessorPluginBase
I'm adding a new patch combining last patch here and last one in conflict issue.
Comment #17
piggito CreditAttribution: piggito as a volunteer and at Skilld commentedThis portion of code is unnecessary since LanguageNegotion plugin already takes care of removing the language prefix. Moreover, it is causing issues since it considers paths starting by /{prefix} instead of /{prefix}/
Considering this I'm attaching a new patch removing this block and also the combined version to include #2924492: url_processor Not compatible with latest Facets UrlProcessorPluginBase
Comment #18
StryKaizerCan somebody confirm that this issue is still an issue?
We changed the routing internals in beta1, which could fix issues like this without extra code needed.
Comment #19
netdreamer CreditAttribution: netdreamer commentedYes @strykaizer, it seems to me that it is still needed: without it, with beta1 (and current dev) we are still getting 404 in the same situation (view for taxonomy with same "base" path as our faceted search).
But patch #17 cannot be applied anymore...
Comment #20
alesbencina CreditAttribution: alesbencina at Agiledrop - Your Trusted Drupal Teammates commentedWhat is the situation with this module right now? is this working, I cant apply patch #17.
Comment #21
Upchuk CreditAttribution: Upchuk as a volunteer commented@alesbencina Please see the project page for updated info on development. If patches don't apply it means other work has gone and it no longer applies.
Is this still an issue? If so, please create a PR on github.
Comment #22
iyyappan.govindHi
I am using this module (version is 8.x-1.0-beta2). Have tested the following
Scenario 1:
1. Created FAQ page using view
2. Created Facet(Source is FAQ view page) and assigned the facet block in FAQ page.
FAQ page path - http:example.com/faq
I clicked the facet link and goes to http://example.com/faq/category/admissions. It shows page not found.
Scenario 2:
Created the landing page for FAQ page.
1. Created FAQ view block
2. Created facet using FAQ view block
3. Assigned above two blocks in panelizer.
Now, clicking the facet, it doesn't filter the result(Ajax). It is showing 404 while loading page.
Hope this helps.
Thanks
Comment #23
iyyappan.govindComment #24
lukasss CreditAttribution: lukasss as a volunteer commentedThere are also other modules that can use views for example LB, TVI ...