1. Home
  2. Docs
  3. Simpods MVC
  4. Basic Components
  5. Linked Areas

Linked Areas

Simpods Linked Areas (Figure 1) is similar to Simpods Hierarchy. The only difference is that Linked Areas allows many to many structure. In some way, you can use Linked Areas as Hierarchy if you are careful enough. The benefits are:

  • Reduce the burden of WordPress tables (termeta, terms, term_relationships, term_taxonomy) for relationship, especially when you just want to link items from two tables, but they are not in hierarchy.
  • “One to many” and “many to many” structures.

  • Custom SQL query is easier as you don’t have to write a lot of join commands to fetch a category title. If you are not bothered about writing your own SQL query, the simpods_select() will do the job for you.

Linked Areas ‹ Simpods MVC

Figure 1. Simpods Linked Areas

Dependencies

The Simpods Hierarchy functionality requires the Pods Framework plugin to be installed, along with the “Advanced Content Type” and “Table Storage” components

How to use it?

There are three fields to set:

  • Main Table: list the Pods table you have created.

  • Friend Table: list the Pods table you have created, except the one you pick for Child Table.

  • Input Type: You can choose Checkbox or Radio. Checkbox means many to many and Radio means one to many.

Let’s learn it from an example: we are a jobs site and we don’t need to create pages to explain each individual category and sub-category. As we know, one job can be assigned to a few categories, and these categories can be assigned to bigger categories, so they are in many to many structure. For instance, a job Graphic Designer can be assigned to sub-categories Game Design, Animation and Illustration. Animation and Illustration can be assigned to bigger categories such as Advertising. Now let’s go to Pods Admin – Add New to create three new pods: Jobs, Job Sub-Categories and Job Main Categories (Figure 2).

Add New - Simpods

Figure 2. Add New Pod

We will pick Custom Post Type and Table Based storage for Jobs, as we need to create pages for them, but Advanced Content Type for Job Sub-Categories and Job Main Categories for the opposite reason (Figure 3).

Add New Post Type - Simpods
Add New - Advanced Content Type - Simpods

Figure 3. Create New Pod

Now if you go to a job, you can find a Linked Area box on the right to assign your posts to (Figure 5).

Assign linked area - Simpods

Figure 5. Assign Linked Areas

A filter will also appear on the posts list (Figure 6) to filter posts by the parent category.

Linked Areas Filter - Simpods

Figure 6. Simpods Linked Areas filter

Coding

If you are using simpods_select(), in your code, do the following to pull out data with its category. In our example above, the Pods table is pods_module-page :

Copy to Clipboard

Do the following to pull out data in a category. Replace {Job Pod ID} with a real Pod ID and {Job sub category ID} with a real job sub-category item ID:

Copy to Clipboard