Just as the title describes, I was wondering if there was a way to use the audio metadata as a views argument the same as a taxonomy term. I think it can be done with views argument handling code, but I couldn't figure out how to pass a filter value as an argument.

Comments

prezaeis’s picture

bump
i need help with this too

deadman’s picture

there's a comment here that may help:
http://drupal.org/node/70145#comment-239920

prezaeis’s picture

no good :(

deadman’s picture

worked brilliantly for me. this is to pass your own filters to views through an argument. are you sure you're passing the argument?

prezaeis’s picture

im not sure what u mean?
i pasted that code into the arguments thing.. is that all i need to do?
could u maybe export ur views code for me so i can use it and modify ?

deadman’s picture

Once the code is in the arguments box it has to be called through a url. for example in the code given in the comment above, you would visit www.example.com/yourviewname/arg0 where arg0 is the first argument (ie genre). the argument part of the url is then passed to the view to show all audio nodes of the genre specified.

you can then add more/different arguments in the same way, just change 'audio_metadata_genre' for 'audio_metadata_artist' etc.
plus you can tell views to look at different parts of the url ($args[0], $args[1], $args[2] etc)

hope that helps

prezaeis’s picture

thank u so much for the reply but this isnt helping me :(

what i want to do is have a view which displays a list of artists alphabetically using the artist metadata tags
i have managed to do this using views and views alpha but there is a problem...
if u look at the page, instead of artists being the linkable title, i have a list of all the audio nodes in an alphabetical order, this causes each artist name to be displayed several times depending on how many audio files they have!!!!!!
i couldnt figure out what to do to fix this

there is a block that comes with the audio module which allows u to click to search by artist name and that does exactly what i want, when u click on artist it takes u to /audio/by/artist/ and each artist is named once in a list and when u click their name ur taken to /audio/by/artist/artistname and u get a list of their songs.... thats exactly what i want except it doesnt allow the list to b sorted alphabetically, its just a long list... is there anyway to look at its code to see how its done?

i really appreciate any help, thank u so much

deadman’s picture

yes, have a look around line 1283 in the audio.module file to see how it works.

prezaeis’s picture

thank u very much, i found the code, do i just paste it into the arguments in views for it to work!?

    drupal_set_title(t("Browse for audio by..."));

    $settings = audio_get_tag_settings();
    $result = db_query(db_rewrite_sql('SELECT DISTINCT a.tag FROM {node} n INNER JOIN {audio_metadata} a ON n.vid = a.vid WHERE n.status = 1 ORDER BY a.tag ASC'));
    while ($obj = db_fetch_object($result)) {
      if ($settings[$obj->tag]['browsable']) {
        $items[] = l($obj->tag, 'audio/by/'. $obj->tag);
      }
    }
    $output = theme('item_list', $items);
  }

  drupal_set_breadcrumb($breadcrumb);

  return $output;
}
deadman’s picture

no, but you can use that code as a basis for building a block that does what you want.

for example, put this code in a php block to enable users to browse by tag:

<?php
    $settings = audio_get_tag_settings();
    $result = db_query(db_rewrite_sql('SELECT DISTINCT a.tag FROM {node} n INNER JOIN {audio_metadata} a ON n.vid = a.vid WHERE n.status = 1 ORDER BY a.tag ASC'));
    while ($obj = db_fetch_object($result)) {
      if ($settings[$obj->tag]['browsable']) {
        $items[] = l($obj->tag, 'audio/by/'. $obj->tag);
      }
    }
    $output = theme('item_list', $items);


  return $output;
?>
prezaeis’s picture

thank you that helps a little but not quite what i want
when u browse to the "browse/by/artist/" page i get a list of all artists in a very long list
what i want is for that list to be sorted using views so the user can click on A or D or X and get a list of artist that begin with that letter

iv been pulling my hair out trying to do this in views but it seems impossible
any ideas?

deadman’s picture

I don't think views can do this. You're going to have to do a bit of custom work for this one. The following sql code will produce an alphabetical list of all artists that begin with the letter 'a', but you'll have to work that into your site yourself as I don't think it will work if you just insert it into the above code.

SELECT DISTINCT a.value FROM node n INNER JOIN audio_metadata a ON n.vid = a.vid WHERE n.status = 1 AND a.tag = 'artist' AND a.value LIKE 'a%' ORDER BY a.tag ASC

As this is getting a bit off-topic, feel free to contact me through my profile page if you'd like me to help more.