I'd like to give users the option to create new content when a certain contextual filter is missing on a panel.

e.g. I have my reviews on a panel. When a review is missing I'd like it to display a block/link to submit a new review.

However my only options are to hide the view, give a summary etc.

How do I do this?

I've found the option for 'No Results Behaviour', but I can't hook into the contextual filter (and then use a relationship to grab a term name). I've also found this work around:


But I'm struggling to re-write the code to pull the term name out of the term id in the contextual filter.


Here I suppose you have added an argument in panel path. You can assign any context to your argument, eg Node: Id. It can be Term as well.

enter image description here

Assign any context to argument like :

enter image description here

Add a visibility rule if Context exists to your view and not exists to custom pane.

enter image description here

  • Sumit I don't really follow. I'm looking at this from the point of view of the ... View. Yes I have an argument from the panel, but I don't follow you after that. Did you read the question I linked? – Pureferret Dec 11 '14 at 14:47
  • So you're saying, "If the argument doesn't exist, skip calling the view", right? That can work in some cases, but say you're checking, "has something been tagged with this term", then the term argument always exists, so this won't help. Do I understand that right? – Letharion Dec 11 '14 at 14:56
  • Well thats correct @Letharion.. In the case you said Views No Result Behaviour will work. :) – Sumit Madan Dec 11 '14 at 14:59
  • @SumitMadan I may have been confusing this with another question I was looking at recently. Reading the question again it looks like this would be a good solution. – Letharion Dec 11 '14 at 15:00
  • I don't think this works as I don't have a node id in that scope. I'm passing it as a value on a link from one view to the next. Does this still work? – Pureferret Dec 11 '14 at 15:00

I managed to work it out, I turned on the PHP Filtering module, and inserted this as a Global text area, with Text format = PHP Code

    $view = views_get_current_view(); //get the current view
    $term =  taxonomy_term_load( $view->args[0] ); // the term id
    $term_name = taxonomy_term_title($term); //get the term id e.g. turn 123 = term_name
<p>No comments exist for <?php print $term_name; ?>.</p>//print out the name
<p><a class="button" href="localhost/drupal/node/add/technology-comments?edit[field_technology][und][textfield]=<?php print $term_name; ?>">Add new comment</a> </p> //link to the add new page, pre-populating with term_name
  • Well if Its just about the Term Name in pane, I suggest you should create a ctool plugin rather than adding php code inside database. – Sumit Madan Dec 11 '14 at 15:57
  • Thanks, @SumitMadan I'll look into it. This looks like a good place to start? – Pureferret Dec 11 '14 at 16:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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