Stillat / relationships

Provides automated bi-directional @statamic entry relationships
MIT License
16 stars 1 forks source link

Making relations available for other fieldtypes i.e assets, taxonomies … #4

Closed hanneshoepfnerio closed 1 year ago

hanneshoepfnerio commented 1 year ago

Hi, thank you so much for your addon. I've was desperately in the need for something like it and build some solution on my own which worked for the project but was not really a addon. Wanted to build something like this for the community, but here you are. Different project right now where I have relationships between assets and originally taxonomies (which can not really be asigned to assets unfortunately), changed it to a custom collection since I was hoping that one entry would do the magic, but I does not.

Therefore the question – is there a way to alter the code that the addon is also working for non entry / collections? In my case I would like to have a one to many taxterm -> assets, or if this is super special, rather assets -> entry of a collection

Thank you!

JohnathonKoster commented 1 year ago

This is something I have started to think about/explore with #2 (the work to refactor to support Users would largely be applicable to the other types of stored content that supports the various required events).

I am still thinking through how that would look (and not break existing implementations). Right now, I am considering something like this (where books is a collection with an author User field, and user:id references the id field on a User resource):

Relate::oneToMany(
    'books.author',  // No prefix defaults to `entry:` for backwards compatibility.
    'user:id' // The `user:` prefix indicates this is a User resource.
);

For a book containing an author, and a cover image stored as an Asset, this may look like this:

Relate::oneToOne(
    'books.cover_image',
    'asset:container_name.field'
);

Relate::oneToMany(
    'books.author', 'user:id'
);
sebszocinski commented 1 year ago

This would be amazing for Entries to Taxonomies

JohnathonKoster commented 1 year ago

This would be amazing for Entries to Taxonomies

This is quite a popular request. Relationship support for Taxonomy Terms will be available in the next release (no timelines to disclose in case things crop up in testing) 🙂

JohnathonKoster commented 1 year ago

Bi-directional support for taxonomy support is available starting with 1.2.0

artemverbo commented 1 year ago

Hi @JohnathonKoster! Big thanks for the awesome plugin first of all.

Just curious if you have any plans to add assets support as well? Having a particular many-to-many use case where "downloads/files" need to be related to a "product" and vice-versa knowing which products particular assets are related to, and this would solve it perfectly.

JohnathonKoster commented 1 year ago

Hi @JohnathonKoster! Big thanks for the awesome plugin first of all.

Just curious if you have any plans to add assets support as well? Having a particular many-to-many use case where "downloads/files" need to be related to a "product" and vice-versa knowing which products particular assets are related to, and this would solve it perfectly.

It's something that I can look into (would have to get a few new events added to Statamic itself); and need to think through asset replacements/uploads. Will let you know! 🙂