CMB2 / cmb2-attached-posts

Custom field for CMB2 for attaching posts to a page.
GNU General Public License v2.0
135 stars 62 forks source link

Adding relationship label to attached posts #38

Open cggit opened 7 years ago

cggit commented 7 years ago

Is it feasible to add relationship labels to the post connections?

Eg. Having a text input field in the attached posts list and storing the text along with the post ID.

jtsternberg commented 7 years ago

Not sure I follow. Please elaborate. You should be able to get any data you need using the id that's stored.

cggit commented 7 years ago

I'd like to label the relationships between attached posts.

Eg. An actors role in a movie where the actor IDs are stored along with their role in the movie's attached post meta.

The only plugin that I've seen do something similar is the no longer supported Post 2 Post which I believe creates a relationship post type and attaches meta data to it for labels.

jtsternberg commented 7 years ago

Ah, I see what you're saying. Yah, that's def. not something this plugin does, and would require some custom coding to make happen.

cggit commented 7 years ago

Would you be able to outline in a few words how one could go about integrating this functionality?

I can code but am not very familiar with the CMB2 core. Any guidance is appreciated.

jtsternberg commented 7 years ago

I'm afraid it would not be a trivial undertaking and would take more than a few words. Basically, you'd have to add the UI to add the label field, then add the JS or php or whatever to process those fields and make sure they are associated with the ids.

cggit commented 7 years ago

Once I have the UI serving relationship labels in $_POST is there a recommended CMB2 hook to add or merge new meta with the existing attached_post meta?

cggit commented 7 years ago

I gave it a go and made a pull request. It works but maybe you can suggest improvements.