- Issue created by @dieterholvoet
- Status changed to Needs review
about 1 year ago 12:34pm 5 September 2023 - Status changed to Needs work
about 1 year ago 11:18pm 8 October 2023 - 🇳🇴Norway matsbla
Thanks for the effort.
I think we need to discuss this a little bit. My plan was to make it possible to configure a view mode for the results, in that case you could configure the display anyhow you want through the UI. However it should then be possible to configure different view mode for each content type.
Any thoughts?
- 🇧🇪Belgium dieterholvoet Brussels
Sounds interesting. Would it still be possible to show results inline in a list though?
- 🇳🇴Norway matsbla
I guess it would, as that can be done using css, right? But if we have a patch to implement the feature we could spend a little time testing on it to see if different scenarios could be covered.
- Status changed to Needs review
10 months ago 11:13am 13 January 2024 - 🇧🇪Belgium dieterholvoet Brussels
I don't think doing this using view modes is a good idea. View modes are good for rendering HTML, teasers or whole pages, but it isn't exactly made for rendering a simple string. I don't really know another place in core where view modes are used for something like this. Also, I don't see how we could make any rendered entity look good in a simple list with a bit of basic CSS provided by the module.
How about we just commit the alter hook? It's ready to be committed and it's the simplest, most flexible solution IMO. If we want to improve further and add something like view modes later we can, but it shouldn't stop us from committing this now. Both solutions can exist together.
- 🇧🇪Belgium dieterholvoet Brussels
A good middle way could be to add a Node label setting where you can change what's displayed using tokens. What do you think?
- 🇧🇪Belgium dieterholvoet Brussels
Thinking about it, that still wouldn't allow people to set different displays per node type. Any chance we could just get this hook merged? I don't see the harm, we could still add another way to control this later. Alter hooks are all over Drupal.
- 🇳🇴Norway matsbla
I've started to make an implementation of the view modes, but didn't finish it yet.
I think we could have a hook, but in that case it should not be just to change the label, but to take complete control of the output (label + link)
- 🇧🇪Belgium dieterholvoet Brussels
@matsbla maybe open a new issue/MR for the view mode feature to keep this one focused on the alter hook
- 🇧🇪Belgium dieterholvoet Brussels
I changed the
hook_anti_duplicates_node_label_alter
hook tohook_anti_duplicates_node_link_alter
. - 🇳🇴Norway matsbla
if ($node->getType() === 'person') {
$label .= sprintf(' (%s)', $node->get('field_last_name')->value);
This seems like part of hard-coded custom code, perhaps should be removed from the patch?