Skip to content

Lots of problems with using 'to' => array(...) #360

Open
@jdolan

Description

@jdolan

Hi,

First, p2p is absolutely awesome. It has saved me a tremendous amount of time on this particular website and I plan on using it often in the future as well. So thank you to the maintainers!

I've noticed that p2p_register_connection_type does some undesirable things when using an array for the to end of the connection. The goal here is to let a particular connection type be available to numerous content types -- ideal for associating generic promotional bits of content to specialized content throughout the site. My example:

p2p_register_connection_type(array(
        'name' => 'features_to_pages',
        'from' => array('event', 'post'),
        'from_query_vars' => array('tag' => 'feature'),
        'to' => array('event', 'page', 'post'),
        'title' => array(
            'from' => __('Featured on'),
            'to' => __('Features'),
    ),
        'sortable' => 'to',
    ));

What happens is:

  1. The from_query_vars no longer limit the from side of the query. In fact, the from side of the query suddenly seems to accept pretty much anything.
  2. Types which are specified only in to are suddenly eligible as from for this connection type. For example, my Pages now have a "Featured on" box in the admin. They should not.

Am I registering the type wrong, or are these valid issues? Do I instead have to create explicit connection types for each target content type?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions