Synonyms should be possible on all types of entities. The Synonyms module is the central repository for synonym handeling -> so it should expand to work on all entities. Content, Users, etc.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

bojanz’s picture

Agreed. The D7 code is very old (think early alphas), so it probably needs someone to do a rewrite.

bucefal91’s picture

This kind of idea never visited me, but I can see some future behind it, and yes, in D7 it becomes much easier to implement synonyms for all entity types...

But talking about user or comment entity type, what is the point to "synonymize" them? and for user, should we make synonyms of his/her username? or maybe of his/her email or let the website administrator to choose the field he wants the synonyms to be based on.

For comments I can't come up with any situation when you might need synonyms for them. I might be too short looking and such situations do exist.

Nevertheless, I think the most demand for synonyms comes exactly from taxonomy terms.

bucefal91’s picture

I keep becoming more and more convinced that this way of development for this module is promising. The module itself is not yet completely mature for such a huge step, at least I think so. I need to give it time and let people use it and get some feedback. But from now on I will keep in mind this possible future path of development while writing code for this module.

Other people, feel free to subscribe to this issue. This way I will see the demand for synonyms for other entity types and together we shall eventually have it done at some point.

adam_b’s picture

+1

ComboPrime’s picture

We need this feature because our taxonomy terms are controlled (no free tagging)--so we have to use an entity reference field instead of a term reference field to add tags. But the Synonyms-friendly widget isn't compatible with the ER field, so it's impossible to get Synonyms working.

RaulMuroc’s picture

+1 for this feature!

bucefal91’s picture

thanks for voting up here. I haven't forgotten about this issue ;) Will do my best to program it too, as soon as I can.

webby7097’s picture

I'd like to see this as well. Using the built in Glossary view, I'd like to be able to add synonyms for the different nodes there without having to create duplicate content.

bucefal91’s picture

Issue summary: View changes

Just a small update here, I still remember about this feature request and actually as I am resolving other issues of this module and refactoring it, I am trying to start introducing enough flexibility to turn the synonyms into synonyms for all entity types at some point in the future. So even though there's no active visual work in this issue, I do keep it in mind and am taking it a tiny step by tiny step closer.

devad’s picture

+1 for this.

Implementing this feature request would bring Synonyms closer to Drupal 8 as well.

bucefal91’s picture

Alright, so the judgment day has come for this long anticipated feature. Here is my proposal:

  1. Keep existing synonyms friendly taxonomy select and autocomplete widgets (why shall we ever remove worthwhile functionality?)
  2. Create a centralized page for managing all synonyms. We could place it at Admin >> Structure >> Synonyms. That page will have a bunch of tabs (each tab for entity type). So the tabs would be "User", "Content", "Taxonomy Term", "Some custom entity that exists in this Drupal", etc.
  3. Underneath the 1st level tabs there will be 2nd level tabs for bundles of that entity type. For example, the tab "Content" will have sub tabs "Article" and "Page", and so on. For entity types that have no bundles we will just omit the "sub tabs" step.
  4. Each of those tabs will pretty much look like current admin/structure/taxonomy/[vocabulary]/edit page (the "Synonyms" fieldset). It will be a table with fields from that entity type in rows and available synonyms behaviors as columns. Then website administrator will enable/disable necessary stuff.
  5. We probably will have to re-think a little bit existing synonyms behaviors. For example, I feel the "include into term synonyms" behavior is too vague and abstract, so I will try to eliminate it.
  6. We will introduce entity reference synonyms friendly autocomplete and select widgets (they will behave similar or identical to their term reference counterpart widgets).
  7. Probably for a couple of releases we will keep "synonyms" fieldset in admin/structure/taxonomy/[vocabulary]/edit, but I personally prefer to remove it, deprecate in favor of centralized page for management of synonyms. Though this item is entirely optional and folks vote to keep it, then at the moment I have no reasons to disobey their will.

Guys, let's see whether you like this plan? I might have forgotten something (being in a noisy place with lots of distractions, so I couldn't fully brainstorm it).

bucefal91’s picture

Status: Active » Needs work
FileSize
108.34 KB

Hello,

Let's see; here's the 1st mock up on the idea. It is still very far from being stable and well tested, though the core functionality is available.

The patch has 100% pass on the existing simpletests, which is good. Though lots of new simpletests have to be added.

  1. I removed the "synonyms" general behavior, since it was too abstract and pretty much useless/confusing to the end user.
  2. Synonyms Search module now supplies term synonyms into node search index even if the term is referenced through entityreference field (used to supply it only if the term was referenced through taxonomy_term_reference field).
  3. Had to change some internal guts of the synonyms core functionality.
  4. Synonyms friendly autocomplete and synonyms friendly select widgets are now available for the entityreference field.
  5. Introduced general location for managing synonyms at Admin -> Structure -> Synonyms

Remaining items that I am aware of:

  1. I didn't invest not even 5 minutes into access logic. I'll have to make sure the access rights are respected for all the entities.
  2. Where I consciously was skipping stuff, I was putting a TODO item, so addressing all of them is pending.
  3. I couldn't quickly decide on the "auto create" feature of autocomplete. Probably it should not be available in the entityreference autocomplete widget, since we might not know the bundle within which to auto create a new entity. Right now I just left it however it was without touching it.
  4. Come up with test cases that cover in full the new functionality and test it manually.
  5. Write new simpletests based on the test cases from the item above and get 100% pass on it.
  6. Right now there is only alphabetical sorting available for synonyms friendly select for entityreference. Do we want to have this kind of sorting too?
    • A entity name
    • Synonym of "A entity name"
    • Synonym 2 of "A entity name"
    • ....
    • Z entity name
    • Synonym of "Z entity name"
    • ....
    • Synonym 999 of "Z entity name"
bucefal91’s picture

So, here's the new iteration on the subject. Since the last patch I got the following:

  • A bit more of real world testing (just trying different scenarios that come to my mind)
  • I permanently removed "auto create" feature from entity reference synonyms friendly autocomplete widget
  • I extended the tests to cover up to a satisfactory level the synonyms friendly autocomplete widgets (both taxonomy term and entity reference)

Remains:

  • Still lots of access logic is not implemented (menu access callbacks, entity access validation in autocomplete and select widgets for entity reference field)
  • Tests to cover select synonyms friendly widget
  • Tests to cover cTools arguments tests
  • Investigate if it's possible to write a general for all entity types cTools arguments plugin just like the existing for taxonomy terms
  • The current set of tests identify a few minor failures that I should address
  • Lastly, the update path... but I will not code it until all the rest is coded, tested, and UX-wise tested
effortDee’s picture

Hi, im interested in entity reference with synonyms as I wish to use this for the flag module and show a flag say 'Is this a good node' and the synonyms be , calm, peaceful, at ease, etc.. Which are synonyms of 'good'.

bucefal91’s picture

Status: Needs work » Needs review
FileSize
198.3 KB

Alright, this patch is a very decent version. I've extended the tests to cover autocomplete widget and term synonyms ctools argument plugin. I made a quick search whether I can write a universal "any entity type" synonyms-friendly argument plugin but didn't find how to do it. It's not a show stopper, so we can leave it out.

We have 100% pass on all the tests and I have tested it manually. At the moment I have nothing more to code. I only would like to change the UI of Admin -> Structure -> Synonyms page (it looks way unfriendly to my eyes, I'll try to think of something different).

Feedback is very welcome!

bucefal91’s picture

Integration with Views (views handlers provided by Synonyms module) was broken, this patch takes care of it.

devad’s picture

Hi bucefal91!

Nice work as always. :)

I didn't have time to play around with "Synonyms for all entity types" yet...

But I can confirm that simplytest.me configuration:

Synonyms 7.1.x + entityreference + patch #16

launches nicely without any errors.

So, if some more community members would like to test new "Synonyms for all entity types" they can do it simply online at: http://simplytest.me

I will defenitely do some tests myself soon... and post results here.

Thanx!

bucefal91’s picture

In the meantime I've manually tested my latest patch and made sure all existing views integration is functional. My tests revealed one issue, so here's the updated patch.

Also, I'll throw out the question to see what others think: Synonyms module obviously will now depend on entity API module. I currently think to block update.php script if entity API module is not installed/enabled supplying user friendly text explaining that from now on Synonyms module has this new dependency. Similarly, I'll include notifications of the same content into the release page and maybe Synonyms project homepage. Would this be enough or there's something more that I can do to facilitate this change in dependencies?

Thank you and hey! Put harder on testing ;) I will not commit this patch until I hear feedback from at least a few people.

devad’s picture

Hi

I have tested current Synonyms .dev + patch #18 together with:

Entity Reference
Drupal Commerce
Term Merge

And results are VERY good.

A few minor issues I have posted as separate issues child-parent connected with this issue.

Aside from posted issues everything else looks great.

Entityreference fields have synonyms friendly autocomplete and select widgets available and they work nicely.

All Entities have their own Synonyms settings and they work nicely.

I have tested Term synonmys, Node synonyms, User synonyms and Commerce product synonyms for now, and they all work great.

Entityreference field of all these kinds of synonym entities works nicely with both autocomplete and select widgets giving properly suggestions from selected synonyms fields of particular enities. Tested with text, integer, decimal, term reference and entity reference field types.

Term Merge module integration looks good as well.

I think this patch is very close to be commited. But more reviews are welcome of course!

bucefal91’s picture

Hello!

Thank you, devad, for your persistent support. I saw the issues you've created. Most of them look as good directions for further extending Synonyms module. However, this one #2667322: Notice warnings at synonyms settings form save is basically feedback about the patch from this issue. I've fixed the issue you found. When I was testing, I was only testing it on the taxonomy term entities and that's why I overlooked it. Along the way I've fixed another subtle defect. So, here's the latest patch.

bucefal91’s picture

I've rearranged some internal things in the SimpleTests (preparing Synonyms module to work with Drupal.org testbot). Functionally this patch is no different from the #20, so there's no need to re-test it.

devad’s picture

Not so many reviews. It seems that D8 is in focus now. :)

I didn't test upgrade path... but if you did and if upgrading works fine can you make commit to some kind of v.1.5-dev or new releace maybe?

bucefal91’s picture

Status: Needs review » Needs work

Hello! :) Yeah, I was expecting quite triple more of reviews than what we've got so far. Silly they are for chasing D8. D7 is quite an awesome piece of software :) Not to mention, D8 does not have Synonyms module (this basically kills all the awesomeness of D8).

My rule of thumb is to give 2 weeks of time and then proceed further. It's about 2 weeks now. There's no update path yet. Not sure if I can do it during the weekend, I already have some arrangements, but I shall deliver it at some point during next week. We'll test it, I'll review the code for the last time and then this new code can go into development snapshot of the module.

I'll be back with a patch in regards to update path one of these days.

bucefal91’s picture

Status: Needs work » Needs review
FileSize
205.07 KB

Hello,

Let's see if this one suits your needs. What I've done:

  • Removed dependency of Taxonomy module from Synonyms. When Taxonomy is enabled, Synonyms plugs in all its rich functionality related to Taxonomy that it has to offer, but it no longer obliges website administrator to have Taxonomy enabled. However, Synonyms Search does require Taxonomy (since whole point of Synonyms Search submodule spins around Taxonomy terms).
  • Synonyms and its submodules on the module admin page have moved from "Taxonomy" group to their own independent group called "Synonyms" (since now Synonyms are not exclusively tied to Taxonomy Terms, they no longer belong to "Taxonomy" group).
  • The taxonomy term reference synonyms friendly autocomplete and select widgets are properly updated in their internal structures in the update path.
  • Old "synonyms" general behavior is clearly removed from Synonyms tables in the update path.
  • Synonyms module blocks any interaction with update.php if Entity module is not enabled along the way presenting a user-friendly message explaining what has to be done before things return to normal.

Devad, so we now have the update path. I've tried testing it from as many angles as I could come up with, but the updates are always tricky. Please, check it out. If you give green light on it, I'd like to let this last patch chill for another 5-7 days here in the issue (just in case somebody else does want to speak up). If we hear no extra feedback, I will commit it when those 5-7 days are up. Then you will be able to access whole functionality from this issue by simply installing 7.x-1.x-dev release (and I am quite confident the dev is stable right now). I am too afraid to tag a stable release right after it, I would like this code to chill for at least a month or few weeks in the dev release (in the meantime I'll try working on other issues we have opened). And then I'll tag a new stable release of Synonyms module with whatever we'll have in the dev snapshot by that time. How does my plan sound to you? Do you have any requests or questions?

  • bucefal91 committed 290304a on 7.x-1.x
    Issue #1194802 by bucefal91: Last review before merging.
    
  • bucefal91 committed 36074a5 on 7.x-1.x
    Issue #1194802 by bucefal91: Working on field widget updates in the...
  • bucefal91 committed 4eff675 on 7.x-1.x
    Issue #1194802 by bucefal91: First intention to write update path.
    
  • bucefal91 committed 5018cd0 on 7.x-1.x
    Issue #1194802 by devad, bucefal91: Processing devad's feedback on the...
  • bucefal91 committed 53e3d7f on 7.x-1.x
    Issue #1194802 by bucefal91: Removing taxonomy dependency from Synonyms...
  • bucefal91 committed 57eaa90 on 7.x-1.x
    Issue #1194802 by bucefal91: Next iteration on the update path.
    
  • bucefal91 committed 86fb8f3 on 7.x-1.x
    Issue #1194802 by bucefal91: Static review and cleaning up few minor...
  • bucefal91 committed a642d55 on 7.x-1.x
    Issue #1194802 by bucefal91: First worthwhile commit on the synonyms...
  • bucefal91 committed c81ad60 on 7.x-1.x
    Issue #1194802 by bucefal91: Fixing removal of 'synonyms' behavior in...
  • bucefal91 committed dff2352 on 7.x-1.x
    Issue #1194802 by bucefal91: Introducing requirement of Entity module...
  • bucefal91 committed e5e9b72 on 7.x-1.x
    Issue #1194802 by bucefal91: Working on field widget updates in the...
  • bucefal91 committed f5f949a on 7.x-1.x
    Issue #1194802 by bucefal91: Preparing SimpleTests for Drupal.org...
bucefal91’s picture

Status: Needs review » Fixed

Holy cow! I've just committed it! :) Now it will reside in the development snapshot for some time. When I feel it got enough testing from the dev release, I'll tag a stable one.

Thank you, everyone, for your support and insisting on getting this feature done. Frankly, I never imagined myself resolving this issue :)

devad’s picture

Hi.

I have done some basic testing of new .dev

I have enabled the module at nicely developed test site with many vocabularies, taxonomy reference and entity reference fields.

I have checked manually created "Price" decimal field of "Offer" content type to be used for synonyms select list suggestions.

Entityreference field which list nodes of type Offer gives synonyms suggestions which include price field nicely.

"836 is price field for offer Weekend in Prague"

Select list is shown by Chosen module and it works nicely.

So far so good. Nice job bucefal91! :)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

bucefal91’s picture

I definitely feel proud to announce that a feature request of 5 years old has been released as a part of stable Synonyms 7.x-1.5 release :) https://www.drupal.org/node/2720481

hehe, thank you, everybody for your patience.