5

I've got a very non-trivial question on integrating Panels and Views. Maybe there's no solution out of the box, but I would really appreciate any help.

Essentially, I've got a lot of tagged nodes. For simplicity, let's say image nodes that are tagged as "flowers", or "animals", or "mountains", etc.

Then I have a view block that displays the images depending on their tag. This view block is then used in panel panes across the website.

Here's the issue: I can't use the URL to pass the tag information. In fact, on the same web page, I need to show several blocks (within panel panes) with different sets of images. One block would show "animals", another one "flowers", etc. And that depends only on the panel pane in which the view block is being displayed.

Of course, I could just create several preset view blocks, one only for "animals", another one for "flowers" etc, but I've got tens of different tags and can't create a separate block for each tag. So I was thinking of a more elegant solution.

Here's what my idea is: when I add content to a panel pane, I've got an option to override the title. I was thinking of adding another text field there "Tags to display" where I would say "flowers", or "animals", etc. Then I would just add the view block to the pane and that view block would pull that tag from the panel pane.

So, bottom line: how can I let the view know in which panel pane it's being displayed? Just pane ID would be enough, the rest (the tag to use) I could simply pull directly from the database.

Thanks for your ideas.

  • 3
    If your View wasn't using a block, but a pane to begin with, wouldn't this be a non-issue? Just tell the pane what to show when you add it to the panel. – Letharion Jan 11 '14 at 23:56
  • 1
    Hi Letharion, I've just come across some other response by you where you mentioned views content panes and that's exactly what I need. I never realised what it was capable of. Thanks a lot indeed. – Mark Jan 12 '14 at 0:18
  • Cool, I'll write that up as an answer then. :) – Letharion Jan 12 '14 at 0:42
  • Hi Letharion, another related question. I've set up a view content pane and it works like a charm, but it takes {tag_id} as an argument which is numeric. Any chance to use human terms like "animals", "flowers" etc? In the case of passing them via URL I would have used a default value setting for the contextual filter and some PHP code. Does the same approach work here as well? Thanks a lot! – Mark Jan 12 '14 at 0:57
  • 1
    Update: so far the easiest way I've found to use "human" tags in content pane filters is to create a separate text field for tags (not using taxonomy) with multiple values (one tag per line) and then you can use the exact same tags in content pane filters. Not as elegant as built-in tagging mechanism with auto-complete functionality, but more elegant than using a numeric {tag_id} in filters. Would appreciate any other ideas. – Mark Jan 12 '14 at 22:45
0

Build your views as "view content pane" displays. That way any context you require for use in contextual filters can be provided in the panel UI when you set up the pane.

  • Answering to remove from the 'unanswered' list. @Letharion gave the answer in comments a couple of years ago. – Darvanen Jul 25 '16 at 6:58

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.