I have a view and panel set up to filter on taxonomy terms. I am trying to replace my legacy views so I can disable the legacy views sub-module. I want functionality that displays taxonomy terms based on URL argument and all values when argument is missing (or wildcard if necessary)

I set up a views pane and panel context to create the same functionality. Before I had a default value for the taxonomy terms in the pane definition which would show all values e.g., 110+111+112. Not real elegant but it worked.

In the new configuration when a taxonomy term is specified in the url it's working fine, but now with no term specified nothing is displayed. I am not seeing how to display all values with a default using the views panes and context. The panel context definition has a taxonomy term as an argument. I tried also putting the vocabulary in as a context in contexts but it doesn't seem to do anything.

I tried various choices in the views pane definition argument source to no avail. I always get nothing for the default display. I tried feeding a wildcard into the url and that doesn't work. The view takes the wildcard just fine on its own. I've tried putting the wildcard * in the view argument and not.

I am also using panesl taxonomy to provide a selection list which conveniently switches terms in the url. So ideally the URL should be like /video for default and /video/110 etc. for a term. /video gives me nothing.

Another strange behavior is when I click the "more" link to see the full view, the url generated has the taxonomy term twice, like /110/110. This may be a panels taxonomy module issue.

Any suggestions?

Comments

stg11’s picture

It seems I struggle with things for hours and right after I post an issue I get it working. I had an extra argument in my view, I think that was the problem. After getting my titles right, I plan to post a tutorial on this.

jeff h’s picture

Mind me asking how exactly you made this work?

stg11’s picture

To clarify what my goal was:
I wanted to create (and did) a view of limited number of video thumbnails in the panel with a "more" link going to the full pageable view. The taxonomy selection is carried over from the panel to the view. The taxonomy term is selectable only in the panel (you could set up a separate taxonomy block to stay in the view and switch terms).

This only works displaying a single-level taxonomy, which is adequate for most applications. If you need a multi hierarchy look at http://drupal.org/node/75626. I am using Panels 2 and the latest version of Views for 5.x. I also installed the Taxonomy Redirect module which allows you to redirect taxonomy/term/nnn to something like video/nnn where nnn is the term id and video is the panel url. This is optional to force redirection to the video panel page when someone clicks on a taxonomy term link shown on a node.

1. created a view with a taxonomy term argument.
-- I selected both page and block in the view. For the page, I used a pager and in the block I used the more link. The URL for the page does not contain /$arg at the end (I had that in there and the default did not show when I did). I have not tried it with the $arg in the middle of the URL.
-- In the default field of the taxonomy argument in the view I selected "Display All Values". In the URL for the page view I did not In the title field of the argument, I entered Videos: %1. The %1 provides the taxonomy term name substitution in the title when navigating to the view's URL.
2. I created a panel view (admin/panels/views, requires Views panes sub-module to be activated). I gave it a name and title, selected Block as the Type, Taxonomy Term as the required context, "from panel argument" as the Argument Source, First as the panel argument, All other options default.
3. I created a panel with the url of video
4. In the Panel Context I added an Taxonomy Term Id argument in the Arguments section. For Default, I selected Ignore it, I put Videos: %term in the title, selected Argument type: Term Id, and chose the appropriate vocabulary by selecting the checkbox. I also used Use Different Default Display which gives me the ability to customize the default (no term specified) page. I did not need to use the Own Display options for the different content types.
5. In the Panel Content I added the pane to the Default panel, using the Panel View I created above (shows up under Views in the selection box). Also added the same thing to the Taxonomy Term1 Default panel. There are two panels in one effectively when you create the taxonomy term argument as I did.
6. In the Layout Settings of the panel, I set the title on the default panel to Videos and on the Taxonomy Term 1 Default panel I set the title to Videos: %term
7. I created a block entitled "Video Channels", making it only visible for video and video/* urls (could be a custom pane in the panel if this works better for your design layout) with the following code, ripped from http://drupal.org/node/88089 (2nd snippet) with slight modifications: changed url and added weight sorting. http://drupal.org/node/21867 provides lots of variations.

<p><span id="video-channel-listing"> <?php
/**
* Creates a list of taxonomy terms for video channels in weight and  then alphabetical order.
* Each term links to the corresponding url with term id
*/

$query = "SELECT tid, name from {term_data} WHERE vid = 16 ORDER BY weight ASC, name ASC";
$result = db_query($query);
while ($term = db_fetch_object($result)) {
  $items[]= l($term->name, "video/$term->tid");
}
if(count($items)) {
  return theme('item_list',$items);
}
?> </span></p>

Make sure you select the PHP input filter when creating this block or pane.
8. In admin/build/taxonomy_redirect, I configured the Taxonomy term redirect for the video channels vocabulary to point to video/!tid

I hope this is enough detail.

jeff h’s picture

Thanks for your above!

I still am unsure whether you actually achieved the "default to show all values" though; from your description above, I believe if you don't supply an arg to the 'video' panel you won't get a list of all videos, rather you'll get the panel page without your view in it (since the view requires the term id context).

Could you clarify that for me?

stg11’s picture

Yes, the default does work. It shows all values in the view pane in the panel. In the View (not panel view, the actual View), in the argument definition, you must specify "Display All Values" in the default field. It should work for you then

sdboyer’s picture

wow @ stg11. That's some dedication :)

One quick note - it was really a mistake to call the legacy views module 'legacy,' let alone deprecated. If that's the reason why you're trying to do away with legacy views, then don't :)

I had a friend request this of me, and I poked at it for a little while, but ended up not having a lot of time to sort it all out. You probably won't be surprised, but I'm fairly sure that the issue basically boils down to a problem with the way that the taxonomy context handles not having a value in it. Instead of delivering empty data to the view (which, as you point out, the view would be fine with and would go right to displaying all values), it simply doesn't call the view at all. I'm about 80% sure that that's what this would turn out to be.

I'm gonna put this on my little 'issues worthy of attention' list...

socialnicheguru’s picture

I setup a panel page
I setup a view pane
the viewpane displays all values if no argument is given

mypage/%term

if I type mypage i get "page not found"

if I put in a value for %term it shows up.

Am I doing something wrong?

frankcarey’s picture

been dealing with this myself. unfortunately you have to make 2 panel-pages, one for mypage, and one for mypage/%. If you are just using the default display, you can try just making mypage, and adding the term context to that and see if it works.

socialnicheguru’s picture

just got a hint from someone

mypage/!term says that the !term is optional. It is in the small print somewhere.

I had to remove !term as a context requirement from my mini panels but it seems to work well.

Chris

esmerel’s picture

Status: Active » Fixed

Looks like folks have solved the issues thought experimentation.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.