I'm using the views module together with the audio and the i18n module. Currently I have a list of all my songs working but now I want to filter them based on genre. I want to do this with an URL argument like view/songs/pop or view/songs/rock

I've added the following code to into the argument handling code pane:

if (isset($args[0])) {
  //sort out the tuples with tag genre
  views_view_add_filter($view, 'audio_metadata', 'tag', '=', 'genre', '');
  //then only pick the pop songs. hardcoded for now...
  views_view_add_filter($view, 'audio_metadata', 'value', '=', 'pop', '');
  //not sure about these two. cut and pasted them from the help-pages
  views_load_cache();
  views_sanitize_view($view);
}
return $args;

but when I try to access the view I get the following message.

warning: pg_query() [function.pg-query]: Query failed: ERROR: syntax error at or near "." at character 439 in /Users/otto/Sites/test/includes/database.pgsql.inc on line 125.
user warning: query: SELECT count(DISTINCT(node.nid)) FROM (SELECT DISTINCT ON (nid) * FROM node) node LEFT JOIN audio audio ON node.vid = audio.vid LEFT JOIN audio_metadata audio_metadata_genre ON audio.vid = audio_metadata_genre.vid AND audio_metadata_genre.tag = 'genre' LEFT JOIN i18n_node i18n ON node.nid = i18n.nid WHERE (i18n.language ='sv' OR i18n.language ='' OR i18n.language IS NULL) AND ( (node.status = '1') AND (node.type IN ('audio')) AND (.tag = 'genre') AND (.value = 'pop') ) in /Users/otto/Sites/test/includes/database.pgsql.inc on line 144.

The tablename seems to be missing here AND (.tag = 'genre') AND (.value = 'pop'). Am I missing something basic here or could this be a problem with the combination of modules I'm using? Any help would be appreciated.

Oh, and btw. thanks for a very powerful module!
--
Otto

Comments

wedge’s picture

Status: Active » Closed (fixed)

I figured it out... This is all that is needed;

if (isset($args[0])) {
  views_view_add_filter($view, 'audio_metadata_genre', 'clean', '=', 'pop', '');
  views_sanitize_view($view);
}
return $args;

Sweet!

ff1’s picture

Version: 5.x-1.6-beta5 » 5.x-1.6
Component: Miscellaneous » Code
Category: support » bug
Status: Closed (fixed) » Closed (duplicate)

This problem has also been reported here: http://drupal.org/node/150517.