3

I'm struggling trying to figure out how to do the following :

  • I have 3 different views displaying content filtered by different features (content-type, custom boolean field, etc.).

  • I want to create 3 panel-pages in which I'll integrate those 3 views. Each of those panel-page will only be displaying the content authored by one different member beetween three specific (named AGS, MM, admin).

  • Thus I wanted to set up a contextual filter in my view which would be the content author ID. Author wasn't available so I chose User : Authmap ID (?). Then, in my panel-page, at Variants > Panel > Contexts I've tried to send a User context by selecting "AGS". I also checked "Send Arguments" in the view settings at Variants > Panel > Content.

... But it's not working ! :( I'd also love to send other context to my views (boolean, etc). But let's first try to make this thing working out...

Anyone's enlightenment will be greatly appreciated ! Thks.

[CONFIG : Drupal 7.4 - and most recent Views and Panels]

4

First thing to do is fix your view. In order to have author ID as a filter you need to add the "Content: Author" relationship. After adding that you will see a lot more options for User in the fields and filters. You can now chose "User: UID" for your contextual filter.

Next thing to do is to edit your panel. Add a user context to your panel and chose "Select a user" for the context type. Type in the username of the user and check "Reset identifier to username."

Now go to your panels content and edit the view settings. You should see the "User: UID" context at the top. Choose the "User ID" from the drop down.

You should now only see content from the user you chose in the context when viewing that panel page.

  • Thank you so much ! So, I've understand well, relationships in Views help bring other kinds of contextual filters, filters, and event fields to you view, while contextual filters are made to expose the view to future context set after (for instance in a panel). Am I right ? – nyoz Aug 8 '11 at 5:49
  • Yup, but Contextual filters aren't just for panels. They are usually passed in the URL (to a view page display type). Panels understands that though, and can pass in lots of things, including URL arguments to that panel (so that it acts exactly like a view page). – rocketeerbkw Aug 8 '11 at 6:32
  • That's one of the points I don't understand : "passed in the URL". Does that mean that the URL to the view is built with those filters or that the view output will be determined by the url being node/12 or node/145 for instance ? – nyoz Aug 8 '11 at 16:41
  • 1
    The latter. If you have a view /articles-by-cat with a contextual filter of "term name", you can create a link like /articles-by-cat/cheese and "cheese" will be passed to the filter and only articles with the "cheese" term will be displayed. – rocketeerbkw Aug 8 '11 at 19:55
2

I was running into a similar problem, I was trying to display a view inside a panel. The view displayed fine, but contextual filters were not working. The reason being, the contextual filters expect and argument and panels uses contexts. (it's really confusing because now they are calling them contextual filters). What I had to do to get it to work is change the style of the view to view pane (you need this module enabled). You will then get an additional menu called "pane settings". One of the settings is argument input, select from context, and it should work fine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.