We have a situation where we need a summary view (done as in glossary mode using the first letter of the last name) on an embed view display that lists people. This type of glossary filtering is a relatively common request.
We don't want to use page displays for a number of reasons, so this embed view is displayed within a node entity (as part of a paragraph type but that is likely unimportant.)
The key is that we need to be able to set a base path for the summary links and not let Drupal simply use the path of the first view page display (of which there is not one.)
Attachments are allowed on embed displays: #2886613: Allow Attachments on Embed Displays so this does seem like necessary functionality.
The base path field in the contextual filter options says: "Define the base path for links in this summary view, i.e. http://example.com/your_view_path/archive. Do not include beginning and ending forward slash. If this value is empty, views will use the first path found as the base path, in page displays, or / if no path could be found."
When no base path is entered, the summary links fallback as expected to / which obviously won't work for us but doesn't throw an error.
When a base path is entered such as 'super-page' (no beginning or ending slashes), I would expect that the summary links would then use "super-page/[letter argument]". However, instead the view completely fails to load and throws the following error:
Symfony\Component\Routing\Exception\InvalidParameterException: Parameter "node" for route "entity.node.canonical" must match "\d+" ("s" given) to generate a corresponding URL. in Drupal\Core\Routing\UrlGenerator->doGenerate() (line 204 of /web/core/lib/Drupal/Core/Routing/UrlGenerator.php).
This error occurs both when using "node/[nid]" and when using the path alias of the node.
Issue fork drupal-3054944
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
jastraat commentedComment #3
jastraat commentedComment #4
jastraat commentedUsing the base path option on a summary view attachment attached to either a block or embed display errors.
Comment #5
kle commentedSame situation: Drupal 8.6.17 - "Define the base path for links in this summary view" will not work (Paths on glossar-Items is )
Comment #10
damienmckennaJust ran into this problem with EVA. Argh.
Comment #13
matslats commentedI'm having a similar issue although it looks like the InvalidParameterException has been fixed.
Now the base path is simply ignored as if the value were ''.
My view has two glossary embed display, one for the given name and one for the family name.
I looked in
This is where the glossaries are rendered.
The first argument for the given name is passed into the first url parameter, resulting in a correct path of /a.
The second argument, which has a base path of 'all' is also passed into the first url parameter, resulting in a path of '/A' instead of '/all/A'.
This all happens in function template_preprocess_views_view_summary_unformatted():
The first parameter should not be in the first position, but the first free position.
Therefore, for this purpose at least, it can be fixed by appending parameters after the ones already set:
Finding the first argument already set with the base_path, it puts the first argument in the second position so that now arg_1 carries the first glossary letter A of the family name.
The temporary fix is to overwrite the theme function. Here's my gutted version
Additional question:
What if the second glossary had too many elements in the base path? This would break this mechanism. couldn't the base_path be populated automatically using the 'all' parameter for each of the preceding views arguments?
Comment #16
vitaliyb98 commentedI believe that for displays not extending PathPluginBase, the summary option for arguments should not be available at least until this is fixed or a better solution is found.
I've added a basic solution as a draft, and I’d be interested to hear your thoughts on it.