Is it possible to get taxonomy term from url and node id at the same time from current node? I need to get taxonomy term from current node to pull some date from referenced nodes that have parent taxonomy of current node term. So far ok. But moreover I need to be able to get to current node's fields. Using another conextual filter to get NID was not helpful.
I don't think you can do this with multiple contectual filters.
Sounds like you need relationships.
Use the contextual filter to get the current nid and show the fields for that node.
Then add a relationship between the node and its terms (you can limit this by vocab if need be) by adding the relationship "Content: Taxonomy terms on node".
Then add a relationship from the term to the parent term by add the "Taxonomy term: Parent term" relationship. This relationship should use the previous relationship.
The add a relationship from the parent term to the content that uses that term by adding the " Taxonomy term: Content with term" relationship. This relationship should use the Parent relationship.
Then you can do extra things like adding filters that use these relationships.
All these relationships can have the "Require this relationship" checkbox checked.
With some relationships you can end up with duplicate results. One way to try to avoid this is go in the "Query options" in the "Advanced" part of the views configuration and check the "Distinct" checkbox.
Relationships can be confusing and they are hard to explain, but if you play around with them, once you understand them they are very useful.
Extra question To answer your extra question of whether you can display the value of one field if it is there and if it is not then show another field in its place:
Yes, you can do that. Depending on your requirements there are a couple of ways it can be done:
- Exclude the secondary field from display and for the primary field check "Rewrite the output of this field" and use the tokens to print the primary and secondary fields out next to each other. This solution will only work if only one or the other of your fields will have a value. If there is a chance that both fields will have a value you will end up with both values printing next to each other.
- Exclude the secondary value from display. Then in a custom module implement hook_view_pre_render() and you can check the $view->result to see if the primary field has a value. If it doesn't you can replace the empty value with the value of the secondary field.
- Override the template for views_view_fields.tpl.php so that if the primary field is empty you print the secondary one. And don't print the secondary one. This could also be handled in the preprocessor function template_preprocess_views_view_fields() in your theme's template.php file.
Unfortunately I don't have time to give code examples right now.