MB Relationships – bi-directional relationships

Support MB Relationships MB Relationships – bi-directional relationships

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #8340
    jo.onjo.on
    Participant

    Like presumably a lot of wp developers, I have been looking for a good many-many relationship solution and tried a few approaches (up to and beyond the point of just writing it myself) but inevitable started and ended with p2p.
    During my research I also investigated this very nice tutorial "Using Custom HTML To Output Anything" (https://docs.metabox.io/using-custom-html-to-output-anything/). Basically this approach evolves around having 'type' => 'post' on one side where you can create connections and have 'type' => 'custom_html' on the other side where you can only display connections. Initially I was very exited about this but abandoned it due to the fact that I really wanted a bi-directional relationship where I could create connections on both sides.
    At this moment I was diving deeper in p2p but today I discovered that you guys created MB Relationships :D!!!

    I am very exited about this extension and played a bit around with it. Now I was wondering, in the documentation is stated that the approach is bi-directional but after setting up the relationship (with the basic usage code) it seems I still can only create a connection on the “from” side and not on the “to” side.. Am I doing something wrong or is this the correct current behaviour?

    I really look forward seeing this extension grow 🙂

    #8343
    Anh TranAnh Tran
    Keymaster

    Hi,

    The relationship is bi-directional by default. That means you can query back and forth with the same API without any problem (or performance issue).

    However, to make the UI clear, the plugin only allows to select the connection from an object to others (the forward direction), and displays the backward connections in another meta box. It's the same behavior in Posts 2 Posts plugin, so I just brought it 🙂

    #8351
    jo.onjo.on
    Participant

    That is not entirely true. The basic usage code from the Post 2 Post plugin creates a relationship from post to page in a similar way:

    <?php
    function my_connection_types() {
    	p2p_register_connection_type( array(
    		'name' => 'posts_to_pages',
    		'from' => 'post',
    		'to' => 'page'
    	) );
    }
    add_action( 'p2p_init', 'my_connection_types' );
    ?>

    But on the admin side I am able to add pages to posts (when editing a post) as wel as add posts to pages (when editing a page), which would make sense for a bi-directional relationship..

    #8368
    Anh TranAnh Tran
    Keymaster

    My bad. I thought it's possible for "from" side only. I will work on that now and update the plugin asap.

    PS: It's done. I will update the extension soon.

    PS2: Just released version 1.1.0. Please update.

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘MB Relationships – bi-directional relationships’ is closed to new replies.