Tell me more ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I have a view that shows taxonomy terms with a relationship to show nodes that have a term reference to that term (relationship not required, aka LEFT JOIN).

For terms that don't have a matching node I would like to show an "add content" link.

The usual "no results" behavior doesn't seem work in this situation. What's the trick?

share|improve this question

1 Answer

up vote 0 down vote accepted

Views PHP to the rescue:

<?php
if (is_null($row->nid)){
    print '<a href=node/add/mytype?edit[field_mytype][und]='.$row->tid.'>add node for this term</a>';
}
?>

I can even pass the tid through the URL and have it prepopulated on the form (using prepopulate).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.