20

I have a page view("/news") with contextual filter for the topics ("news/design","news/coding"...) which are taxonomy terms and this worked fine. Due to some changes for the mobile theming, I need a block view instead of the page view, but I can't get it to work with the filters.

With the old filter settings I get all my articles in "/news", but the filter I am using changed the default value from the filter to "taxonomy term ID from url"; I now see an empty page for "/news" (this is now a simple page with the block view included) and a "site not found" for "/news/design" etc. In the preview of the view, everything works fine.

These are the settings for the view.

screenshot

0

1 Answer 1

34

In general, the reason this block isn't working is that a block does not have an assigned path and the contextual filter does not have a path to work on. To connect the block to a path return to the contextual filter settings and in the section What to do if the URL is not available select Provide default value and select Raw value from URL from the dropdown box. From the Path Component box select the position in the URL that your contextual filter gets its value.

In your specific case you have told the view to interpret the URL as a taxonomy term and that is probably not the format of your URL (taxonomy/term/tid). The Views UI is a bit misleading in that it suggests that the alias can be used in the contextual filter when it does not. Drupal converts the alias to the base URL value when it calls the view and that is what is directly available in the contextual filter. To use the alias you must specifically inform it as described above. Views is powerful, but a bit tricky to use. One tool you can use if you have some experience with SQL queries, is to turn on the display of the queries in the View preview display in the Settings tab. This will tell you what views is trying to do when the view is called.

More can be found on this issue at this question

4
  • Hi, thanks a lot for the detailes reply. Now i see what is ment by taxonomy term. Unfortunately it also does not work with the "raw value from url". It is really difficult to debug, because in the preview everything works fine. Is there something else that i do not see?
    – user6670
    Apr 9, 2012 at 16:05
  • 1
    If it works in preview, but not on the site, that implies that the problem is not with the view settings. It may be that the view is not getting the URL. Is the view block being placed in a theme region? Is a quick tab or other specialized display module that calls the view block directly involved?
    – Ashlar
    Apr 9, 2012 at 19:32
  • I don't know about user6670, but this answer saved my butt today. Thanks, @Ashlar!
    – beth
    Jun 12, 2012 at 17:51
  • 1
    I had success using this solution but one thing that should be mentioned is that all the contextual filters need to have a default value. Once I set all the contextual filters to "Provide default value," "Raw value from URL" and picked a position, this solution worked great.
    – user9717
    Sep 4, 2012 at 5:54

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