Comments (23)
you're right, it is not that easy...but is's on my todo list
from cockpit.
+1 from me. This would also solve my need for taxonomies.
from cockpit.
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.
cockpit("collections")->find('CollectionTest')->populate('test')->toArray();
It's a bit rough around the edges, but it's a start. Your input would be highly appreciated!
from cockpit.
@StevenDevooght You provided some ideas that I need to elaborate, thanks!
from cockpit.
+1 for Collection relations, Actually its the only thing holding me from using cockpit in a bunch of projects i have lined up.
from cockpit.
I'm already working on solving this issue :-)
from cockpit.
@StevenDevooght I have a first solution for linking collections in the master branch, maybe you want to try it out?
from cockpit.
@aheinze Just tested it and it looks like its getting the job done.
from cockpit.
@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.
from cockpit.
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!
from cockpit.
@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
from cockpit.
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?
from cockpit.
I also tested it right now and works like a charm! Thumbs up for the other changes, too.
from cockpit.
Great improvment !
I'm trying to use it.
I have a collection col, with a linked collection coltype. How can i read the coltype element of the col ?
Trying this :
<?php foreach(collection("col")->find() as $item): ?>
<h5>< ?=$item["nom"];?></h5>
<?php foreach($item["coltype"] as $col): ?>
<h6>< ?=$col["coltype"];?></h6>
<?php endforeach; ?>
<?php endforeach; ?>
Doesn't work :(
from cockpit.
someone can help me ?
from cockpit.
@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.
from cockpit.
;) thanks, but it's just a mistake in the copy/paste... but that doesn't work :(
from cockpit.
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());
from cockpit.
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?
from cockpit.
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.
from cockpit.
Aha ok, forgot about the MongoDB cursor.
from cockpit.
Would these collection links and their linked data be accessible from the JS/REST API as well?
from cockpit.
+1
from cockpit.
Related Issues (20)
- fitToHeight not working same as fitToWidth (Image API)
- #[\\ReturnTypeWillChange] Deprecation Error
- Screen Lock Login HOT 1
- Bug: The order of nested layout modules reverts back to the first saved state on the second save.
- [Recommendation] Documentation is preparing.
- cms date gte
- PHP version requirment is 7.1 or 7.3? HOT 2
- Can I global disable the finder? HOT 1
- Is there a way to restrict assets folder per group?
- Apache userdir wrong redirect
- Linked items: Collection entry must contain a "name"-field
- placeholder (null or "") doesn't work with textarea
- Wrong sorting: list of languages HOT 5
- Jobs queue HOT 1
- Provide documentation for this version HOT 2
- Get unpublished collection items HOT 1
- UX Suggestion: Dismiss confirmation modal with ESC HOT 3
- How to upload assets via API?
- [BUG] Collection can't remove correctly.
- Collection List Blank on broken Content Link
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cockpit.