I have one panel that I want to override multiple content types with. I would like to have a view that lists based on the content type being viewed. Is there a way to pass the type of node being viewed as an argument to a view?

CommentFileSizeAuthor
#6 context-node-type-444456-6.patch803 bytesduellj

Comments

gdoteof’s picture

I was able to solve this by choosing in the view an argument for 'taxonomy:term' and using php code for when an argument wasn't available

if ((arg(0) == 'node') && (is_numeric(arg(1)))) {
$nid = node_load(arg(1));
$tids = taxonomy_node_get_terms_by_vocabulary($nid,8);
  $output = '';
  foreach($tids as $tid) {
   $output .= $tid->tid. "+";
  }
  $output = substr($output, 0, -1);
  return $output;
}
merlinofchaos’s picture

Status: Active » Fixed

That's as good a way as any of doing this.

gdoteof’s picture

hrm, i won't change this back, but is there an inherent reason why only one term can be passed via panels to a view as an argument? it seems to be a valid feature request to send multiple terms

gdoteof’s picture

wow sorry, I don't know what is going on here. I had another issue where I was trying to pass multiple terms of a specific vocabulary to a view, and that is the code I used. The code doesn't really apply to the intended question, except the general idea of using php to determine the node type.

I just looked at the code and then at your response and made mine without looking at the original question.

duellj’s picture

Status: Fixed » Active

Changing this back to "active" since the code posted by gdoteof doesn't pertain to the original issue.

duellj’s picture

Project: Panels » Chaos Tool Suite (ctools)
Version: 6.x-3.0-alpha4 » 6.x-1.x-dev
Component: Plugins - content types » Code
Status: Active » Needs review
StatusFileSize
new803 bytes

Here's a patch for adding in the node type as a context for ctools. It's pretty basic, but it works for passing the node type as an argument to a view.

merlinofchaos’s picture

Status: Needs review » Fixed

With the current system, the appropriate way would be to make a type converter so that the type can be pulled as a string. This is trivial to do, so I did it.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.