NooB Question: Views and Arguments

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
datatv's picture

I've been having the problem all morning where I'm so close to creating my first view but it's just not there yet. Here's what I've done so far.

I'm creating a recipe book using CCK to add a new content area called Recipes. I've created a couple of taxonomy categories. One for ingredients and one for recipe category. They show up whenever I add a recipe to the category. Fine so far. Now I'm in views and no question, it's confusing. I add a page display and to that I add Arguments called Taxonomy: Term, where I have '%1' for the title, Display all values if argument is not present, wildcards are 'all'. From there I have in the Fields area, Node: Title as I just want to display the title of the recipe, Sort Criteria is set to Node: Title in ascending order and lastly, Filters are set to Taxonomy: Vocabulary. I go to Live Preview to add my term and it works. Only the recipes using that term are listed. Great. But I'm confused in that shouldn't I add that argument to the Arguments panel? Also, when I click on the View "Page" link, I get a 404 error even though the path I set is correct. So how can I get this page to display and how do I get it to show the proper arguments. Not just in Live Preview but on the page itself?

Comments

Views Help

mike stewart's picture

Views is like a visual SQL builder. the main thing to be aware of when starting is choosing the right fields and the right filters.

Until you're more advanced, stay away from arguments. Arguments are like dynamic filters. In other words they are filters that can be passed from the URL or using PHP.

Start here, info on views in the handbook: http://drupal.org/node/109604
Note: if you're using Drupal6, then you're using Views2.

There are also a lot of good videos on it, including from local LA folk. checkout drupal-la.blip.tv and also checkout the unedited [ videos from DrupalCampLA 2009 | http://replay.nacs.uci.edu/public/summer2009/DxLA/] - google will find you more.

--
mike stewart { twitter: @MediaDoneRight | IRC nick: mike stewart }

Pass the argument in the url

apperceptions's picture

Sounds like you have it all set up correctly. You just need to pass the arguments via the url path to the view.

For example, if you want to define a menu item to look at tomatoes, you would use a url like http://yoursite.com/yourviewname/tomatoes.

This assumes that you have selected the Argument type to accept names or names & ids.

By default, it wants something like http://yoursite.com/yourviewname/123

I'm assuming here that tomatoes has taxonomy term id 123 (you can see the number when you hover over a link to the term).

This assumes your view path is set to something like yourviewname/%1

Also, one of the behaviors for no match is to display a 404, so this may be in effect.

All these settings are in the arguments section, under validator options.

The same ideas apply even if your path is more complex, like yourview/%1/%2 where %1 is the vocabulary and %2 is the term.

So I'm guessing that things are set up correctly and it's just a matter of going to the correct url with the correct params in the url and in the format expected by the view.

Hope this helps.