verbb / many-to-many Goto Github PK
View Code? Open in Web Editor NEWA Field Type plugin for CraftCMS that allows the management of relationships from both sides
License: MIT License
A Field Type plugin for CraftCMS that allows the management of relationships from both sides
License: MIT License
I am using the Many to Many plugin and wondering if the below is possible.
I have a channel called Model ID. Model ID is then related to two other sections, Memory and SSD. I want to be able to link entries from Memory to entries in SSD via the Many To Many Field within Model ID.
Below is a picture, edited, to show the field layout and the information I have within the Model ID entry. The information within the entry is what I need to pull in to my Memory and SSD section but can not figure it out.
I feel like I am missing something very simple that might not be in the read me document for the plugin.
Here is a link to the question [on StackExchange]
(https://craftcms.stackexchange.com/questions/26696/many-to-many-plugin-template-help
)
Thanks for your help!
Seems like "use Craft\base\Field;" should be "use craft\base\Field;" where craft is with small letters. Causing class not found error.
We have two sections: Organisation Entries and Job Entries. Each Job Entry has a "organisation" relationship field that selects one organisation. In the organisation entry itself we added a many-to-many relationship field called "relatedJobs".
There is no way to filter the organisation entries to only show organisations where the relatedJobs
is not empty.
Testing this with the built-in relationship field on the job entries this is working without an issue.
query GetOrganisationsWithJobOffers {
organisationsEntries(relatedJobs: ":notempty:") {
... on EntryInterface {
title
}
... on organisations_organisation_Entry {
relatedJobs {
title
}
}
}
allOrgEntries: organisationsEntries {
... on EntryInterface {
title
}
... on organisations_organisation_Entry {
relatedJobs {
title
}
}
}
jobsEntries(organisation: ":notempty:") {
... on jobs_jobOffer_Entry {
title
organisation {
title
}
}
}
}
Result:
{
"data": {
"organisationsEntries": [],
"allOrgEntries": [
{
"title": "Some Organisation",
"relatedJobs": [
{
"title": "Some Job Offer"
}
]
},
{
"title": "Some Other Organisation",
"relatedJobs": []
}
],
"jobsEntries": [
{
"title": "Some Job Offer",
"organisation": [
{
"title": "Some Organisation"
}
]
}
]
}
}
4.5.6.1
3.0.4
No
No response
When editing an entry, and clicking the "add entry" button. The modal body table is empty.
I only have this problem when using relations where the section of the original field and the section of the manytomany field are the same section.
When I use the same field between different sections, the field works as intended.
I'm using https://github.com/verbb/events for events and sessions. Each event can have many sessions. I'd love to be able to set up two-way linking between them.
As of Craft CMS v3.4.6.1 while using the current version of the plugin available through this repo, I am seeing an error returned when attempting to add an entry to a Many to Many field.
Failed to load resource: the server responded with a status of 500 (Internal Server Error)
/index.php?p=admin/actions/element-indexes/get-elements&v=1582172064925:1
error: "Argument 1 passed to craft\elements\db\ElementQuery::enabledForSite() must be of the type bool, null given, called in ~/vendor/craftcms/cms/src/elements/db/ElementQuery.php on line 516"
Application Info
PHP version 7.3.14
OS version Linux 3.10.0-957.27.2.el7.x86_64
Database driver & version MySQL 5.7.29
Image driver & version GD 7.3.14
Craft edition & version Craft Pro 3.4.6.1
I've a many-to-many relation set up. I've tried two approaches to work with eager loading, but can't figure it out.
craft.entries.section('relatedSection').relatedTo(entry).all()
// Result ok but doesn't pair with eager loading
entry.relatedSectionFieldName
// Result empty
For the regular relation, this last approach does work.
Hi,
I want to translate this plugin to dutch, but many of the text strings you're using are not going through the translate filter. For example: "Add an entry" is always in english. Can this be fixed?
I really like the idea of this field type, but it would be great to let us use it with Commerce Product. I'm adding Categories to my products and would like to see all of the associated products when I go see my Categories entry page.
I'm perplexed!
I have a many to many relationship where one side is an Entries Subset field and the other is Many to Many. The relationship is between two entries in the same structure (different entry types).
Everything works perfectly in the CP. When templating, however, I can access the entries subset field, but the Many to Many field returns null.
The field shows the correct linked entries. But adding or removing relations, do not save.
4.3.10
3.0.2
No
No response
Is there any way to relate entries of the same type to each other? For example, a channel of 'person' might have a 'spouse' field where you choose another person to relate. It'd be great if you could use this plugin to set up the two-way relationship but currently it only works across entry types.
Great work though, really useful!
Anything in the roadmap to have this be compatible with CraftQL?
Will this plugin be update to work with Craft 4?
I've tried to use $entry->setFieldValue('manyToManyFieldName', $otherEntry->id);
and then save the entry using the elements saveElement() method. However that doesn't seem to work. Is there something simple I'm missing here?
Calling Craft.createElementSelectorModal
seems to be removing the Field completely from the DOM in the tooltip.
I assume that I wouldn't need to do anything after upgrading from Page 8's many to many plugin, but I got errors in the CP like this on all the many to many fields: Unable to find component class 'Page8\ManyToMany\fields\ManyToManyField'
. I wonder what I did wrong.
I didn't run composer require verbb/many-to-many && composer remove page-8/craft-manytomany
, but I remove page-8/craft-manytomany
and specify "verbb/many-to-many": "2.0.0"
in composer.json
, and run composer install
(without composer.lock) together with Craft & bunches of other plugins I want to update. I assume this is the same as running composer
require and composer remove
as you suggested.
It would be great if you can advise.
PHP version 8.1.9
Craft edition & version Craft Pro 3.7.61
#Deleting entries from the many-to-many field works, but adding them, I get a blank screen with no entries to select in Craft 3.5.17
Would love to be able to easily see which elements are related to an asset when selecting it
I can't seem to use arguments for the many-to-many field via GraphQL? The part (limit: 3)
of the example query results in an error. Without
query example {
entry: artistsEntries(slug: "jackson-michael") {
... on artists_artist_Entry {
title
summary
tracks (limit: 3) {
title
}
}
}
}
Unknown argument "limit" on field "tracks" of type "artists_artist_Entry".
tracks
)query example {
entry: artistsEntries(slug: "jackson-michael") {
... on artists_artist_Entry {
title
summary
tracks {
title
}
}
}
}
query example {
entry: artistsEntries(slug: "jackson-michael") {
... on artists_artist_Entry {
title
summary
tracks {
title
}
}
}
}
4.5.6.1
dev-craft-4
Yes
No response
Thanks for the plugin! It would be cool if while setting the second associated field we had an option to limit the maximum number of entries allowed. For example, I use it to associate journal publications with its print issues, and while one issue could have many publications, a publication could be related only to a single issue.
Hi!
When trying to add a (reverse) relationship from a Many to Many field, the element select modal opens up empty (no elements to select from).
Probably because of changes introduces in Craft 3.1, ref: https://craftcms.com/guides/updating-plugins-for-craft-3-1#update-element-source-key-references
So it seems this is easily fixed by changing
'section' => $relatedSection->id
to
'section' => $relatedSection->uid
in craft-manytomany/src/fields/ManyToManyField.php
> getInputHtml()
Thank you for providing a nice plugin!
Craft 3.1.15 with project.yaml
Seems like the latest version of the plugin is not available with the Craft (Pixel & Tonic) Plugin store:
I was testing out the plugin so I created some dummy fields. I happened to name the fields in a way that the many-to-many field was last in the CP. When I deleted the other fields, the many-to-many ceased to work (as expected), but also was unable to be deleted.
Upon refreshing the page, I got a runtime error and was unable to access the CP, even at the highest level of the CP (/admin
) that. I have since restored a backed up database, but the error was something like class manytomanyfield failed
.
In this environment it was fine, but a check for that would be helpful, as would a disabled state where I could delete the field. If a user added that to a more important environment, it would have disabled everything and been unable to fix from the CP.
Edit: This was in Craft 3
New self-managing relationships are great, thank you!
It took me a little while to figure out that you've added some settings to manage this - I was looking all over in the many-to-many fieldtype for an "add button" and trying combinations of fields to get it working. Maybe mention that the options of which you speak are inside new plugin settings! That would save some other unsuspecting folk some time.
Thanks again
Hi again,
Have just encountered a small issue upgrading to Craft 5, looks like it'd just be the ->
here and here
5.0.0-beta.6
4.0.0-beta.1
No
No response
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.