Relationships between custom taxonomies in WordPress - wordpress

I’m interested in defining relationships between custom taxonomies but I’ve been unable to find much in the way of documentation on this topic. Perhaps this can be done using the Pods framework (?), but I'm not sure. What I’d like to be achieved is the following:
There’s the ‘found_object’ custom post type.
There’s the ‘materials’ custom taxonomy for terms like plastic, wood, glass, etc. attached to the ‘found_object’ post type.
There’s also the ‘physical_properties’ custom taxonomy for, say, electrical conductivity and other properties that a given material is known to possess.
I would like to assign the above properties to my materials so that the physical_properties taxonomy terms for each of the found_objects get auto-populated once the materials of an object are selected. Or to reiterate: if an object has one or more materials assigned to it manually this will automatically assign all the properties of these materials to the object and different materials should obviously be allowed to share the same properties.
I need this to let the user arrive at these objects by filtering them by physical properties directly (not by materials per se) using the FacetWP plugin.
I vaguely understand that this can hopefully be done using the Pods plugin by setting up a relationship between my taxonomies by creating a relationship field. But other than that I don’t quite understand what to do.
I would greatly appreciate your help or suggestions.
Kind regards, Svetlana.

The problem can be solved by using the Pods framework in tandem with the FacetWP plugin (by taking advantage of one of its indexer hooks) as is demonstrated here (with the link to the relevant code snippet included).

Related

Meaning of Term Reference in Drupal

I am learning Drupal. I saw youtube videos which teach Drupal. I frequently hear the word Term Reference while learning it.
I google out and searched reference link but could not get clear concept of it.
So can you please briefly explain
what is the Term Reference and why to use?
tl;dr Read blockquote for basic understanding, rest is examples to clear your thoughts.
In drupal, taxonomies(terms and vocabularies) are a type of
entity like nodes, users. And reference fields are used to refer
these entities in another entities.
So, a term reference field will be used to refer a term. So if I place
a term reference field in a content type, then I can successfully
access terms(related to term reference field) in nodes.
These terms are used to organize contents. Please refer this for more
info: https://www.drupal.org/documentation/modules/taxonomy.
A good example of organizing contents will be in E-Commerce sites. For example: All the products(nodes) can be organized into Shirts, Pants, Shoes etc. using term references(shirt, pant, shoes respectively). And then I can use this field to fetch only shirt products or shoes products.
In vanilla drupal, tags is a reference field used in Article content type. When you create many articles tagging them to some terms like first. Then you can fetch all the article with term first.

How to create the best Drupal 7 structure as a site builder - via Entity type or Content type?

Just started using Drupal and tried to understand the core concepts. I have a developer background but I would like to use Drupal as a site builder and not digging into the code.
I'm trying to build a website which lists various vendors. One could be a Restaurant, another can be Photographer and other possible services (I have like 15 different ones).
They all have some things in common like Title, a Location (used Taxonomy/Vocabulary for that), description, image gallery, address, website, office hours and so on.
But they also have some custom fields. Restaurants can have fields like Facility options:Parking, Smoking area, etc or Capacity; Photographers can have others.
So there are lots of fields which are common for each vendor and some are are unique per each vendor.
What's the best way to implement this kind of structure as a Site builder?
I tried using Entities via ECK (Entity Construction Kit) and defining Entity types (as Vendor) and Bundles (as specific Vendors) but then I'm really limited in defining the common fields on Entity type level since Properties does not seem to be flexible in this regard, meaning that I cannot define them as normal fields and can't associate to them various widgets but only as a text input. Not sure if this a limitation of ECK or of Drupal 7 itself?
On the other hand I see the option of creating normal Content types for each kind of vendor which seems like alot of repetitive work, not sure if this is the right way (that's my only option at the moment)?
Maybe I should start learning more of Drupal and do some coding to create specific entity types? - but this means being more than a site builder. Since it will be a big project will this save me of some trouble later on or you see that I can accomplish the task easily without this extra effort?
Also by coding I'm not sure if there are easy ways of defining fields/widgets for Entity type Properties.
I would later on want to use faceting as well for filtering which will be based both on the fields which are common and unique for each vendor type, not sure if this is an important factor when creating the structure.
Any feedback is appreciated!

How to filter custom content type nodes using ajax in Drupal?

I'm in a situation where I think I need to create my own custom search module. What I'm trying to do is make a page with a list of all my nodes in the node type - let's call it 'Beer'. So I want to be able to filter through the beers in a fashion similar to the one you find on the Apple Trailers page ( http://trailers.apple.com/ ).
I tried using Views 2 but ran it to a few problems:
I can't make the filter links like in the top of the trailers page (exclusive, just HD etc.)
The search function will only search one field (Exposed field "Beer title" but I also want it to search for manufacturer and other things.
I'm aware of a couple of solutions:
I could fix the last problem by using the Computed Field Module where I could combine the fields I want to search through. I just don't see this as a very elegant solution.
I could make my own module and create my own database queries where I apply the relevant filters (I just don't know how).
I could somehow use my already installed Solr module.
So the first solution - the easiest I guess but also kind of bad with duplicate content in my database.
The second solution - the best (maybe) - problem: I'm too dumb.
The third solution - Solr seems pretty cool but would I be able to present my beer nodes with just the title and a picture?
So I guess my question is. Which one of the three would you use? Or what other solutions could I potentially use (I'm confident there are things I haven't thought of :))?
Sounds like this could be a good use for Taxonomy not different node types. Also, Have you considered http://drupal.org/project/quicktabs ?
You could set up each "filter" as a tab that passes an argument down to a view. Then don't expose any views filters to the user.

Can Drupal terms in different Taxonomies be synonymous?

Let's say
Taxonomy_A is associated to Node_Type_A
Taxonomy_B is associated to Node_Type_B.
AND
Both Taxonomy_A and Taxonomy_B have a term called 'yellow'.
Is it possible to make terms 'yellow' synonymous, so that if I'm looking at a list of 'yellow' stuff, I'm seeing content of both types (Node_Type_A, and Node_Type_B)?
Progress:
Unfortunately it is not possible for taxonomy terms to behave in Drupal as described in my question (at least not without forcing it):
It is clear by taking a look at the terms_related table that it would be possible to create paths that forced related terms together using the taxonomy_get_related function regardless of what vocabulary the term belongs to:
However, the way to get to these terms is through the taxonomy_get_related function in the taxonomy module. This function is not used at all in drupal-6 core except to define it. (I did find it once in the ctools module).
I think you are doing it wrong. I mean using taxonomy wrong, not technically, but as a concept. Ask yourself why do you have 2 vocabularies with term yellow? Both are colour. they belong to same dictionary. Maybe tell little more of what you are trying to make.
Maybe you need to change setup so you don't associate one dictionary to one content type, maybe CCK, views and this module can do what you need http://drupal.org/project/content_taxonomy

Is there a way to get distinct taxonomy terms in drupal views?

I am trying to get a list of distinct taxonomy terms in drupal using views2.
It seems it shouldnt be that big of a problem, however when i select the taxonomy:all terms, and select what vocabulary to limit to i get duplicates.
The "distinct" option in drupal does nothing, and i cant find anything else that groups it together.
If anyone knows anything that would be great.
Thank you.
/Anders
In case of taxonomy terms, views2 applies the distinct clause to the term id, which is rather useless in your case. So afaik there is no way to do what you want in views2 without manipulating the view via custom coding.
So you might want to take a look into hook_views_query_alter() for an option to manipulate the query used by the view. Alternatively, you could execute the view via code and filter the resultset found in $view->result after execution of the view.
But depending on what you need the list for, those methods might be a bit overkill compared to just ignoring the views module for this task and doing the query directly in code from a custom module.
The problem you have having is what you actually are doing is to get all the taxonomies that match on every node on your site. A quick hack would be to create a node (doesn't need to actually be published) that contains all of the taxonomy terms, then you could limit the nodes to only that node and you would get a list of all taxonomy terms you want.
Else I would go for one of the options that Henrik Opel suggested, personally I would just make a little custom module for this, and make the queries myself.
Views is a very powerful module, but in some cases, it's actually a lot easier and faster to just do the queries yourself. Especially when the display is not so complicated. You could even use the templates that views has to render your data, if you don't want/need to create your own.

Resources