-
-
Notifications
You must be signed in to change notification settings - Fork 528
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Collection relations #54
Comments
you're right, it is not that easy...but is's on my todo list |
+1 from me. This would also solve my need for taxonomies. |
I started to work on a proof of concept for the relations. You can see the result here: https://github.com/StevenDevooght/cockpit/tree/collection_relations For now it only supports one to one relations. I added a 'find' method to the collections public api so the populate method can be called on the ResultSet class.
It's a bit rough around the edges, but it's a start. Your input would be highly appreciated! |
@StevenDevooght You provided some ideas that I need to elaborate, thanks! |
+1 for Collection relations, Actually its the only thing holding me from using cockpit in a bunch of projects i have lined up. |
I'm already working on solving this issue :-) |
@StevenDevooght I have a first solution for linking collections in the master branch, maybe you want to try it out? |
@aheinze Just tested it and it looks like its getting the job done. |
@aheinze Some feedback, It would be nice to link to more the one entry for example if i have a posts collection and categories collection then a post could be linked in to more then on category. Also a nice feature would be to define which field of the linked entry i want to display on entries list page, example i have a posts collection and categories and my category collection as a field named "NAME" then on the posts entries list i want it to show the value of the "NAME" field of the linked categories instead of the linked category ID. Nice progress and thanks for putting your time on this. |
I didn't find time yet to give this a test, but I will do for sure. As @bainternet suggested the logical next step is to add one to many linked collections which shouldn't be to difficult with the base logic already in place. Keep up the good work! |
@bainternet thanks for testing! the link collection field shows the same fields you define as "Fields on entries list page" on the collection edit page. @StevenDevooght + @bainternet to define multiple collections links I want to go a step further and make it possible for every field, with a "multiple" setting that you can set in the collection edit view |
Just had a quick look and it's getting there! Picking a linked collection is pretty straightforward using the dialog, which can even be enhanced using search filters. Any idea what the public api will look like? |
I also tested it right now and works like a charm! Thumbs up for the other changes, too. |
Great improvment !
Doesn't work :( |
someone can help me ? |
@crealx Not to sure if its the problem but if you look at lines 2 and 4. I think the blank space between "<" and "?" will stop PHP from picking up to process it. |
;) thanks, but it's just a mistake in the copy/paste... but that doesn't work :( |
I just commited a helper function to populate a collection resultset with linked collections: 522a28a#diff-8b75f95e1a5b573ee0f68ddecbfa9f86R47 Usage: $result = cockpit('collections')->populate('colname', collection("colname")->find());
// or
$result = collection_populate('colname', collection("colname")->find()); |
If I want to populate all linked collections configured on for instance a 'News' collection I have to use the following method which works flawlessly. $result = collection_populate('News', collection('News')->find()); What confuses me is the first parameter of the collection_populate function. The scope of the ResultSet is already dealing with 'News' items. Is it necessary the repeat this again with the first parameter or am I missing something here? |
the point is, that you don't have a context...the resultset can be either an array or a MongoLite/MongoDB cursor. The MongoLite cursor knows the context, the MongoDB cursor not. I know it looks strange...but well, it works for now. |
Aha ok, forgot about the MongoDB cursor. |
Would these collection links and their linked data be accessible from the JS/REST API as well? |
+1 |
Adding a relation field to the collection type would be a great enhancement. This would make it possible to link collections together.
Content editors would get a search dropdown where they can search through the referenced collection type.
I don't know how difficult it is to add something like that to the current code base or if it even fits the lightweight philosophy of this project.
The text was updated successfully, but these errors were encountered: