Can Drupal terms in different Taxonomies be synonymous? - drupal

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

Related

Relationships between custom taxonomies in 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).

drupal display the rest category article

i have create a category CMS,and add three terms to it (drupal,joomla,wordpress). when i create an article which belongs to drupal.now i want to show the rest drupal's articles(belongs to the term of drupal ) at the bottom of the article .is there a module to get this or how to write the code to get that.thank you.
I think the Similar by terms module will do what you want.
Coding this is not a bad way to learn some drupal coding skills. If you want to do your own, post here and I can give you pointers.
edit
You will need to implement hook_block() to create and define your block.
I suggest that you start with outputing some dummy text to prove to yourself that you have got it working.
You can then use menu_get_object() to load the object, and make sure that you only return something on node pages.
As part of your node object. Use var_dump on what is returned from menu_get_object to see what is there, there will be a taxonomy, which you can interrigate to get the appropriate term.
Then you can use taxonomy_select_nodes() to get the nodes.
Let us know you if you run into any issues.

Drupal: How can one use Context to trigger a reaction for a Taxonomy Term condition caused by a View?

What I would like to do is use the Context module to insert $body_classes of my choosing based on a Taxonomy Term condition. Fine, that's what the Context module is for. Seems simple enough IF your content/page source is a node that is involved with the appropriate Terms. However, I have a page generated by Views that has the appropriate Taxonomy Term id that SHOULD trigger the condition but it doesn't.
Now I could set my $body_classes in a "preprocess" in template.php but I'd rather avoid that. Is this even possible in Context? Or am I just doing something wrong?
For what it is worth here is my two cent :
When working with drupal modules, I have found that when i know a module (or combination of modules) is almost doing what i need, and i try and push them to the limit, i find myself wasting far more time trying to make the modules do that "x" feature, than it would take to code my own simple little module.
So for "edge cases", when it looks abvious that you need a very complexe setup/config to achieve something (if you ever can achieve it with the mods in hand, just go and code your own little custom module.

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.

Drupal question: Views, arguments and nodequeues

Hello :) I posted this same question on a drupal-oriented site, but didn't get any replies at all. I grumbled to myself and wished that the site was more like StackOverflow, so I thought, why not try asking it here :)
I'm playing around with a view that displays nodes belonging to a taxonomy term. The vocabulary also has a taxonomy nodequeue with subqueues for all the terms.
So far the view has one argument, taxonomy term ID, and is sorted by post date. But what if I wanted to display all of the nodes of a particular term, with all the nodequeue nodes on top, and all the non-nodequeue nodes (but still under this particular taxonomy term) below, sorted by date?
To clarify, say this is my vocabulary, we'll call it 'living stuff'
Plant
--Fruit
--Vegetable
Animal
--Fish
--Dinosaurs
The following nodes are found under Dinosaurs:
Tyrannosaurus Rex (added 2009-01-01)
Megalosaurus (added 2009-01-02)
Velociraptor (added 2009-01-03)
Brachiosaurus (added 2009-01-04)
Since tyrannosauruses and velociraptors are extra awesome dinosaurs, they're also added to the nodequeue living stuff, subqueue dinosaurs:
The subqueue:
Velociraptor
Tyrannosaurus rex
The final view should display them in this order:
Velociraptor (it's first in the NQ)
Tyrannosaurus Rex (2nd in NQ)
Brachiosaurus (of the remaining dinosaurs, this is the newest)
Megalosaurus (oldest non-queue dinosaur)
I created a relationship to a nodequeue, but it wouldn't let me pick a subqueue, I could only limit to the 'living stuff' nodequeue.
My first view argument is term ID, so I thought that if I added "Nodequeue: subqueue reference" as the second argument, I'd get the expected behavior, but this only shows the dinosaurs listed in the nodequeue.
Any help or suggestions on this problem would be highly appreciated. Thanks!
I haven't really tried much with nodequeues' subqueues, so I'm not completely certain of this. But from my experience with nodequeues, it seems like when using views, you are limited to the basic things they support and can't really do the type of customization you are looking for. I think your best bet, would be to create your own views sort handler, where you can sort it like this. It will probably be quite tricky to make such a handler, since you have to figure out both views and nodequeues in order to make it work. You should really give it some thought if it would be worth it before venturing down that path, unless you have done this sort of things with views before.
More hacks:
A work-around for the behavior your trying to accomplish might be to forgo using nodequeues at all. I'm not sure the entire impetus for using the nodequeues nor the importance of dates, but faced with similar issues before, I've been able to tackle it using the following:
Sticky
Modified dates
If you sticky your super-cool dinosaurs, and modify the published dates of the elements so that they match your order, you could produce what you're looking for in a single view. It's sorta hokey, and it's predicated on not really caring about publishing dates (something that always depends on situation) nor having a more pressing reason for using a nodequeue. That said, if you don't need the nodequeue or the dates, it's a workable solution.
The 2-view solution by Jeremy should be workable, too, and I'd say that's another common way to handle the given scenario.
Hacky solution warning!
Have your primary view in your page with the nodequeue items.
Create another view which is exposed as a block for the non nodequeue items. Put this block in the main content region and limit it to only show on URLs which are the same as the first view.
You may have to do some fiddling with the url variables but I think it will work.
Why don't you concatenate the views behind each nodequeue? (each nodequeue generates a view)
You can add a header (see 'Basic Settings' in view edit page) to the second nodequeue that contains php code that invokes views_embed_view('first nodequeue') (you just need to change the header's input format to 'php'). Or rather, create a custom view that includes each nodequeue by invoking views_embed_view(). This would effectively place one nodequeue on top of another, and if they are of the same format/content type you don't even need to mess around with fields: you can use Row Style == Node. As far as your arguments, they can be passed to views_embed_view, as the third parameter (the docs don't say that AFAICR, but I found a post in the forums (http://drupal.org/node/99721) that indicated args can be sent as '$current_view->args' to the view being embedded).
HTH

Resources