I have a view with an argument of Node: Content Type. I have a panels page for the node_view page which is loading the view. I'm trying to pass the content type of the node being viewed to the view, but I have a feeling it is passing the human readable name instead of the machine name. The use case is that I'm trying to display a list of nodes of the same type as is currently being viewed. Does it sound like I'm doing something wrong? Otherwise please tell me where to start debugging this. I've attached the export of the view.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

merlinofchaos’s picture

You only have a block display, which makes it much more difficult to actually pass data. How are you trying to pass this content type to the view?

merlinofchaos’s picture

Status: Active » Postponed (maintainer needs more info)
mstrelan’s picture

FileSize
6.22 KB

My page variant of node/%/view is attached. The content type argument is passed in the bottom pane.

  $pane->configuration = array(
    'context' => array(
      0 => 'relationship_entity_from_field:field_precinct-node-taxonomy_term_1.tid',
      1 => 'argument_entity_id:node_1.content-type',
      2 => 'argument_entity_id:node_1.nid',
    ),
  );

Note that my view now also has a third argument to exclude the current node.

merlinofchaos’s picture

Hm. For entities we're using core tokens, which is how things get converted. Dave Reid tells me that token.module provides a machine name -- are you using token.module? You may need to for this.

mstrelan’s picture

are you using token.module

I do have the module enabled, not sure if I'm using it in this instance.

The reason I thought it may be using a human readable name is that I added "new custom content" to my page and entered something like %node:content-type and it printed "Dining outlet" instead of "dining_outlet".

merlinofchaos’s picture

The actual token for the machine name is %node:content-type:machine-name I believe.

mstrelan’s picture

Status: Postponed (maintainer needs more info) » Active

Thanks but that didn't work. I went in to page manager, edit the content of my variant, edit the settings of my view pane. There I changed the select list for the Content Type argument to "No Context" and in the Arguments text field I entered %node:content-type:machine-name. The view did not display. Still so far the only way that works is to enter the actual machine name in to the aforementioned text field. The only success I did have was that adding a custom content pane with %node:content-type:machine-name displayed the actual machine name instead of the human readable name.

PS. In these situations where I have provided more info do you want the status set back to "active" or should I leave this for you to change?

merlinofchaos’s picture

PS. In these situations where I have provided more info do you want the status set back to "active" or should I leave this for you to change?

Definitely back to active.

I think I may finally understand what is wrong here. This patch should allow you to make this work.

This patch relies on a commit I *just* pushed, so you will have to apply this to a very recent -dev.

merlinofchaos’s picture

Whoops. I hadn't saved a file. This patch is better.

mstrelan’s picture

Status: Active » Reviewed & tested by the community
FileSize
3.88 KB

There is a bracket missing at the end of the addition to views_content_views_content_type_render(). Updated patch attached.

I have tested this with a views page display displayed in a panel with the content type argument passed from the node panel context. This worked perfectly. I have not tested with pane display and not quite sure what the view_from_argument hunk is for, but I imagine they should work also.

njivy’s picture

This bug bit me, too. When will it be included in a stable release?

zabelc’s picture

This just bit me as well...and I was unable to get the patch above to resolve the issue.

I'm putting %node:content-type:machine-name into the argument, and it's not recognized by views at all. I'm printing out the argument in the "No Results Behavior", and I get "Club News:machine-name == Content: Type input". Thus it looks like it's being a bit too greedy in it's evaluation of the token string.

merlinofchaos’s picture

Status: Reviewed & tested by the community » Fixed

#12 would be an unrelated bug to this. The patch itself is one I actually thought I had already committed and did not. I feel bad about that.

In any case, committed and pushed!

Status: Fixed » Closed (fixed)

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