问题
I'm trying to set a contextual filter for a block type views but when I preview it, it returns nothing... More specifically when I try the same view as a page the Contextual filter is working fine and filtering the content but when I try the view as a block nothing is returned although the "Provide default value" is set as "raw value from url". Any idea what might be the problem? By the way I tried the solution here but it's still not working https://drupal.stackexchange.com/questions/13868/drupal-7-views-contextual-filters-with-page-blocks
回答1:
When using views as blocks you need to enable ajax for the filters to work specially if its exposes.
go to advanced -> other -> and enable ajax and see it it works.
cheers, Vishal
回答2:
i ran into a similar situation: i was using content title as the contextual filter for a page, but when i tried to use the same filter for a block, the block doesn't show up. when i set the filter for the block (just the block) to content nid and set the default value to 'content id from url' it worked like a charm EVEN THOUGH THE CONTENT ID IS NOT IN THE PATH ALIAS. weird.
回答3:
This might help someone...
I had the default view set correctly (in my case: raw url -> /part 2/, tick path alias) and the validation criteria set correctly (taxonomy term -> tick correct content type -> term name converted to id) but I was passing a third argument from my views_embed_view function call:
<?php print views_embed_view('recommended_documents', 'three', **$node->id**); ?>
I believe the arguments from the third onwards become the contextual filters values that are checked against, which we're looking to override with the raw URL.
回答4:
The solution was to re-install drupal, no idea why, clearing the cache wasn't helping.
来源:https://stackoverflow.com/questions/8081977/drupal-7-views-block-and-contextual-filter-not-working