PICK (column)
(Since 1.2.0) -- Relationship columns
A relationship column is essentially a select list containing items from the related type. If you create a column in one pod that relates to another pod, "event", then in the edit form you'll see a select list with all "event" items.
Relationship Types
| Type | Details |
|---|---|
| Pod | an item in one pod can relate to items in another |
| WP Page | a pod item can relate to one or more WordPress Pages (only fields available on the wp_posts table will be usable in findRecords relationship usage; i.e. related_post_field.post_title) |
| WP Post | a pod item can relate to one or more WordPress Posts (only fields available on the wp_posts table will be usable in findRecords relationship usage; i.e. related_page_field.post_title) |
| WP User | a pod item can relate to one or more WordPress Users (only fields available on the wp_users table will be usable in findRecords relationship usage; i.e. the_user_field.user_email) |
| WP (Parent) Category | if a category has children, then a pod item can relate to one or more of these children (only fields available on the wp_terms table will be usable in findRecords relationship usage; i.e. the_category_field.term_id) |
Creating a Relationship
- Click the "Add new column" button
- Enter a name and label
- For the Column Type, select "Relationship (PICK)"
- Select the pod you want this column to relate to (or one of the WP items)
- Save the column
Filtering / Ordering PICK Items in the Form
There are two options for Relationship fields, "Filter" and "Orderby". These interact with the MySQL statement to select the values.
Values should reference non-PICK column names, with a t. prefix. The values here have not yet had any tables joined, so normal findRecords syntax will not work. The only exception here is WP Taxonomy, which gives you access to the wp_terms (t prefix) and wp_term_taxonomy (tx prefix) tables.
Examples
Filter Examples
is_active=1or
event_date>NOW()
Orderby Examples
is_active DESCor
event_date ASC
Bi-directional Relationships
Bi-directional Relationships, as the name suggests, allows you to make "double sided" relationships. With Bi-directional Relationships it's possible assign a pick column to a pod and, for the pod picked, a "reverse pick" to that first pod.
For example, you've got 2 pods: "author" and "book". To create a bi-directional Relationship, you'd add a "related_books" PICK column in your "author" pod, and a "related_author" PICK column in your "book" pod.
Then, let's say that you add 10 new books. For each book, you select an author from the dropdown list. With a bi-directional relationship you won't have to go back into the author pod and manually select the related books from the dropdown. So every time each item is updated, the relationships on both sides will be updated.
Creating a Bi-Directional Relationship
- Click the "Add new column" button
- Enter a name and label
- For the Column Type, select "Relationship (PICK)"
- Select the pod you want this column to relate to (or one of the WP items)
- Save the column
- Go to the other pod, repeat steps 1-4, and now go to the second drop-down below the drop-down you select the related Pod / WP Object -- Select the first field's name from the list
- Save the column
- Go back to the first pod, and now go to the second drop-down below the drop-down you select the related Pod / WP Object -- Select the second field's name from the list (if it doesn't show up, switch the related Pod / WP Object away from the current selection and then back to refresh the list of fields)
