views:

191

answers:

2

I have a view set up to accept 2 arguments. The url is like this: playlists/video5/%/%/rss.xml It works fine if I supply the url with 2 arguments like playlists/video5/front/coach/rss.xml. I have 2 arguments of "Taxonomy: Term"

But I need it to run even if 1 or no arguments are supplied. It looks like you can do this with PHP Code under: Provide default argument options -> Default argument type: -> PHP Code.

I'm using this for the first one:

$arg[0] == 'all';
return 'all';

I'm using this for the second one:

$arg[1] == 'all';
return 'all';

It's working fine in the preview if I enter 1, 2 or no arguments, but in the browser it giving me a "Page not found" error if I use less than 2 arguments in the url.

It woks with these urls: /playlists/video5/gridiron/all/rss.xml /playlists/video5/gridiron/football/rss.xml

It does not work with this: playlists/video5/gridiron/rss.xml

I want it to return all values when no arguments are given, or if only one arg is given, just use the one, etc...

thanks

+1  A: 

Views will only collapse the %, not the slashes surrounding it. So while you're trying to use playlists/video5/rss.xml, Views is expecting playlists/video5///rss.xml.

To get what you're looking for, you need to duplicate the View display you're using twice.

For the first duplicate, use playlists/video5/%/rss.xml as the path. In your arguments for this view display, make sure the first argument validates for either gridiron or football.

For the second duplicate, use playlists/video5/rss.xml. There will be no arguments for this view display. If you just want all of the records to show up, you shouldn't have to do anything more. But if you want to supply a default argument other than all the records, you'd override the view display and create a filter instead of an argument.


Another (less ideal) option is to treat gridiron/football as one argument and validate it that way.

Mark Trapp
Thanks Mark. What I don't understand is that it asks you to provide a default value in "Action to take if argument is not present:"->"Provide default argument", for "Fixed entry" I put "all". and in the view preview it works. In the "Live Preview" it shows this as the path: "playlist-xml-video/all/all/all/all/all" showing me that is does fill in the missing values, because I put nothing in the Arguments text box for the preview.
EricP
+1  A: 

I would rearrange your URL to look like this: playlists/video5/rss/%/% so that way your arguments always come last. Then in your argument settings set:

Action to take if argument is not present: Display all values

This way when you go to playlists/video5/rss you will get every value. When you go to /playlists/video5/rss/term1 you will get all values that have term1 in them. Then the trick for the second argument is to include the wildcard for first argument like this: /playlists/video5/rss/all/term2. I believe that will include just the values that have the second term.

Alternatively, if these are both taxonomy terms, you may want to consolidate these into a single argument and check the box that says: Allow multiple terms per argument. According to the documentation right below the checkbox, it looks like this should allow you something like playlists/video5/rss/term1+term2 and display all values that have the first or second term.

bkildow
Thanks.I guess there is no way around having to fill in the empty vars with "all" for the empty ones is there? That's really what I want, because I some of my editors may not remember that they need to fill in 5 variables, and I may need to change it to more later on.
EricP