4

To reduce duplicated panel pages for every view I want to display, I'd like to re-use the same panel (the same layout) for several views. The problem is that I can't find how to include ANY view in panel where view is passed by argument or URL. There are only particular Views Content panes available but this results in creating as much panel pages with URLs as there are views. And any changes in "common" panel content elements must be made for every panel page which is overkill.

There is analogue solution for nodes - predefined panel "node_view" ("/node/%node") which can display ANY node's content passed in URL. There's an element "Node content" which does that. Is there similar solution for views? Thanks in advance!

  • 2
    What are the different arguments/contexts you are using? You're putting the emphasis on the wrong word, node/%node can include any NODE, but ONLY nodes. If you can't predetermine the incoming contexts, then how would Panels/Views know how to act? You can work around it by making the View arguments optional, but control their behaviour with custom access controls, but most of the times one would do that, I would say "You're doing it wrong.". As always though, I'm sure there are some, rare, use-cases where it's actually appropriate. – Letharion Oct 13 '12 at 13:51
0

If you can use a PHP snippet in your panel you could use views_embed_view($name, $display_id = 'default') to render the view from url.

Let's suppose your panel's url is /mypanel. You can use /mypanel/myviewsname/displayname to access that panel with a particular view and display using the following code in a PHP snippet:

<?php
$display = arg(2)?arg(2):"default";
print views_embed_view(arg(1), $display);
?>

arg() gets a list of arguments passed through url. views_embed_view() embed a view in a PHP snippet and it will return nothing if no adequate view name is passed. This should work whenever myveiwsname is an actual view name and displayname is an actual display of that view or is not provided.

You may be able to include PHP in a panel only if you have PHP filter module installed.

You should use PHP filter module with caution.

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.