- Issue created by @asb
- 🇭🇷Croatia devad
At ./admin/structure/synonyms I am getting a configuration page where I can, for example, enable the field "Synonymous name" in my node type "Person".
Next steps example:
1. Add few "Person" nodes with their titles and "Synonymous name"s. For example:
- Title = Lionel Messi / Synonymous name = Leo Messi
- Title = Christiano Ronaldo / Synonymous name 1 = CR7, Synonymous name 2 = CR9
(Note that you can configure the "Synonymous name" field to be multiple if needed.)2. Install Entity Reference module and add entity reference field "Person reference" to your "Article" content type. Select "Synonyms friendly autocomplete" as widget for your new "Person reference" field.
3. Go to "Add new" article form. Now you can find/select Persons inside your "Person reference" field here by typing both Person's title or Person's Synonyms name (for example: CR7) into the "Person reference" field widget.
Let me know if this helped. :)
- 🇩🇪Germany asb
Hi devad,
thank you for your reply. The example use case you are describing is pretty much what I was hoping to accomplish with Synonyms. However, I believe that the 7.x-1.x branch does not have this functionality. That's the reason why I asked for a confirmation as I might have overlooked something.
From what I can see in my D7 site is that one could use Synonyms 7.x-1.x to mimic the behaviour of D6/D5 core taxonomy where synonyms used to be a built-in feature.
What Synonyms 7.x-1.x - imho - can no do is what you are describing. There is no way I could find so far to tie an entity reference field to synonyms. I believe this functionality was added in the module versions for D8, D9, D10 or whatever comes next, but it is not yet available in the 7.x-1.x branch. But again, I might have overlooked something.
- 🇭🇷Croatia devad
All the steps described in my previous post are both for Synonyms version 7.x-1.6 (recommended version), and the more recent 7.x-1.x-dev.
If you follow the steps carefully it should work for you as well.
- 🇩🇪Germany asb
Ok, so where do I tell Drupal to consider the synonymous name field for the person node title?
This is neither possible at ./admin/structure/synonyms nor at the content type field definitions (e.g. ./admin/structure/types/manage/person).
- 🇭🇷Croatia devad
Go to:
admin/structure/synonyms
and then click "edit" next to your "Person" content type bundle. You will find yourself at the path:
admin/structure/synonyms/node/person
Here, at "Synonyms settings of Person Nodes" table, you need to enable the "AUTOCOMPLETE" checkbox for the "Synonymous name" field. - 🇩🇪Germany asb
As I mentioned in OP, at ./admin/structure/synonyms I am getting a configuration page where I can, for example, enable the field "Synonymous name" in my node type "Person". At the path ./admin/structure/synonyms/node/person, I can enable the "Autocomplete wording" with a checkbox, and I can enable the "Select wording". The default autocomplete wording is: "@synonym is a synonym of @entity".
According to the documentation page for Synonyms 2.x → , this is the first configuration step which sets up a field to serve as synonyms provider. Then, in Synonyms 2.x there would be a 2nd configuration step called "Manage behaviours", and "Adjust the widget type". I do not have similar settings in synonyms 7.x-1.x-dev, so at this point I can not follow the documentation anymore.
If I set up a View with a "Content: Title" field and an exposed filter on "Content: Title", views searches only in the node titles and not in the "Synonymous name" field. I think the reason is because these two fields have not been conneced. The first step as described above enables the "Synonymous name" field as synonyms provider generally. Though there is no way to tell Drupal to use this synonyms provider for what. In this example this would be: Use the synonyms provider field "Synonymous name" as synonyms when searching on the Person node titles in a View.
Or to use another example which avoids Views: Use the synonyms provider field "Abbreviation" as synonyms when searching on the "Organization" node titles in an entity reference with "Synonyms friendly autocomplete" widget. However, this "Synonyms friendly autocomplete" widget has another side effect as it breaks or does not support the "Entity reference prepopulate" and "Prepopulate Create Node Links" modules (which allow to create non-exsiting nodes on the fly with a modal dialog). So as far as the "Synonyms friendly autocomplete" widget is concerned, I might be encountering a simple module incompatibility.
- 🇭🇷Croatia devad
It looks that Synonyms for Drupal 7 does not have fully functional Views integration for Views filters.
You can try a workaround... to create new filter group of two filters (unexposed) like this:
....
AND
Content: Title (contains) OR
Content: Synonymous name (contains)You can also use the "Is equal to" or any other available operator here if it fits better your use case.
And then install the Views filters populate → module and apply "Global: Populate filters (exposed)" filter to above two filters. Also go to your View "Advanced settings / Query settings" and mark the "Distinct" checkbox to avoid duplicates.
Please note that this workaround currently works with PHP <= 7.4 only due to Views (for Drupal 7) PHP8.1+ bug. See: 🐛 "Rearrange filter criteria" - can't add a new filter group Fixed .
- 🇩🇪Germany asb
Lucky me is running legacy PHP version 5.6.40-0+deb8u12… meaning that your workaround to use synonym[ous terms] without synonyms [module] worked like a charm. I think this can really help to avoid duplicate nodes when one has to deal with pseudonymous names or nicknames, misspellings, alternative spellings, transcriptions and the like.
And I guess I am beginning to understand what the problem of the synonyms module is (or at least my trouble with it). The logic to deal with synonymous terms sits mostly in 'proprietary' (synonyms friendly) widgets, and search and views implementations, and not where it (imho) belongs - in core. I think the more powerful architecture would be if every field would have a button "enable synonyms support", and Drupal core would have to deal with feeding terminological ambiguity to all default facilities like views, search and references/relations. It is absurd that the maintainers of a contributed module are forced to duplicate so much core funtionality 'just' to enable a feature that even more belongs into Drupal core than translations. For usability and data consistency, radical synonyms support would have incredible potential. Anyway, unfortunately we can not change this, and things are as they are.
So to summarize and answer my initial question: The 7.x-1.x branch does not only mimic Taxonomy synonyms as we are used to from D5 and D6. At least under certain circumstances, it supports entity references as well. However, in reality there are a number of obstacles (e.g. module incompatibility with the "Entity reference prepopulate" and "Prepopulate Create Node Links" combo), and limitations (e.g. Views filters integration for "Taxonomy Terms" and "Entity Reference" fields only) to deal with which might become a showstopper, depending on the individual use case.
Also I got to know the 'Views filters populate' populate module which allows to quickly build a workaround to use synonyms in views exposed filters without even requiring the synonyms module.
Devad, many thanks for your help, you have been awesome!
- Status changed to Closed: works as designed
over 1 year ago 9:03am 4 August 2023