Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
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.
Comment | File | Size | Author |
---|---|---|---|
#10 | 1229478-Unable-to-pass-content-type-machine-name-fro.patch | 3.88 KB | mstrelan |
#9 | 1229478-view-context-raw-tokens.patch | 3.3 KB | merlinofchaos |
#8 | 1229478-view-context-raw-tokens.patch | 2.5 KB | merlinofchaos |
#3 | 1229478 page variant.txt | 6.22 KB | mstrelan |
views content type argument.txt | 17.45 KB | mstrelan |
Comments
Comment #1
merlinofchaos CreditAttribution: merlinofchaos commentedYou 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?
Comment #2
merlinofchaos CreditAttribution: merlinofchaos commentedComment #3
mstrelan CreditAttribution: mstrelan commentedMy page variant of node/%/view is attached. The content type argument is passed in the bottom pane.
Note that my view now also has a third argument to exclude the current node.
Comment #4
merlinofchaos CreditAttribution: merlinofchaos commentedHm. 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.
Comment #5
mstrelan CreditAttribution: mstrelan commentedI 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".
Comment #6
merlinofchaos CreditAttribution: merlinofchaos commentedThe actual token for the machine name is %node:content-type:machine-name I believe.
Comment #7
mstrelan CreditAttribution: mstrelan commentedThanks 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?
Comment #8
merlinofchaos CreditAttribution: merlinofchaos commentedDefinitely 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.
Comment #9
merlinofchaos CreditAttribution: merlinofchaos commentedWhoops. I hadn't saved a file. This patch is better.
Comment #10
mstrelan CreditAttribution: mstrelan commentedThere 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.
Comment #11
njivy CreditAttribution: njivy commentedThis bug bit me, too. When will it be included in a stable release?
Comment #12
zabelc CreditAttribution: zabelc commentedThis 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.
Comment #13
merlinofchaos CreditAttribution: merlinofchaos commented#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!