2

I'm trying to display a view in a block, the content of which is based on value of one of field of currently displayed node. I found out that I must use Views content panes and Mini panels modules. I created appropriate view in format "content pane" and I'm stuck. I can't find how to proceed any further. I tried to create new mini panel but I don't see how to associate one with another.


Clarification

I choose Panels after quick research because I want to display view in a block, which takes arguments from it's context: field value of current node. Nodes are displayed using standard template and Display Suite.

Clarification 2

What I exactly want to do: take field value from currently displayed node and in a block in sidebar display list of nodes that also have same value in that field.

2

I got it!

  1. Create views block type display that requires context filters.
  2. Create block with PHP filter content type.
  3. Put into it code:

    <?php
      $node = menu_get_object();
      $field = field_get_items('node', $node, 'field_NAME');
      echo views_embed_view('VIEW_NAME', 'block_1', $field[0]['value']);
    ?>
    

(this eventually can be moved into custom module to avoid using PHP filter)

  • 1
    awesome!!..nice and clean.:) – Neo Oct 5 '13 at 18:29
1

Do you really want to add mini-panels? based on your question, you want to display a view in a block. You can just create a block display of a view. this can be added to a normal panels page (as you want to have this view display contents based on the field value of the node) I am guessing that you have overridden the node template by panels and now you can embed the block display of the view directly in the panels and pass in the context of the present node.

I am not sure you even require mini panels. Answer can be pin pointed if you make your question more clear to give out what is that you are exactly looking to do.

UPDATE:

Ok, yes panels can very easily come to your rescue here. So that part is good, you can pass in field value as context.

So how to add a content to a panel (or mini panel) is same as what ankit explained in his answer. the trick is that when you try to add a views block to a panel, it will give you an option to pass context for panels to views per "contextual filter" you have defined in a view.

So here are the steps:

  1. Create a views block type display.
  2. obviously you will be adding some contextual filters which accepts arguments from panels. (remember this contextual filters are what will accept arguments from panels)
  3. While adding this view to panels through steps mentioned by Ankit in his answer, pass in the required argument per contextual filter you have added.

In order for me to help you to configure the view, you heet to let me know what exact stuffs you are looking to add in a view and how are you planning to construct it functionally. Hope this helps.

Update 2:

Mini-panels are not listed in blocks page. Mini Panels are listed in mini panels page. Also mini Panels do not have a dedicated page. They are meant to be embedded into a parent panels page. I don't think you need mini panels at all. As per my Understanding, here a couple of pointers.

  1. I think you are trying to add a view to a mini panel and have it available as block and place it in a region in a page. this will not work out as mini panels are never available as blocks.
  2. I am not sure about display suite, but now if you want to use this mini panel, you need to override the node template with panels.

You need to understand that Panels/mini panels and display suites are two different approaches to do the same thins. Here is a very good resource to know more.

UPDATE 3:

Just found an awesome module that might just do the trick for you through a views only approach. This module provides a views display that gets directly attached to the node and gets tokens from node field that you can use as view's contextual filters directly.

Here is the link to the module.

  • I added some comments and updated my answer. – Neo Oct 5 '13 at 16:06
  • I created mini panel and added view into it, but I can't found it on admin/structure/block page. – user11153 Oct 5 '13 at 16:33
  • I think you are confusing the basic here. please check my updates. – Neo Oct 5 '13 at 16:47
  • "I think you are trying to add a view to a mini panel and have it available as block and place it in a region in a page." - yes, this exactly. So I must enable Panel nodes module and use it to style node? – user11153 Oct 5 '13 at 16:51
  • Absolutely yes, if you want to use mini-panels you need to use a panel override of the node template. but what worries me is that i think this approach might be serious overkill for your purpose. Can you give me an idea what things you are trying to display in that view in a bit more detail? I think this can be achieved simply through a view, not sure though (will depend upon your requirement). once I have the details I can guide you in the proper direction. but if this views approach only approach does not work, you may go in for the panels override. – Neo Oct 5 '13 at 17:21
0

To make mini panel acts like a block try the following:

  • Select the mini panel for editing and select the "content" editing display.
  • Next pick the gear (present in the upper right corner of the desired region in the mini panel) and select 'add content', the pop-up will give you the selection of available content that can be placed in the panel.
  • Once you have the mini panel configured, you place it in a theme region just as we do for block: select the mini panel from the admin/structure/blocks page for your theme (It can be found in the list of disabled blocks at the bottom of the layout page form).

Also you can have look at the tutorials that may be helpful for you:
http://drupalize.me/videos/basics-views-content-panes
https://drupal.org/node/1704274

  • I created mini panel and added view into it, but I can't found it on admin/structure/block page. – user11153 Oct 5 '13 at 16:34
  • Can you clear the cache and chech, It can be found in the list of disabled blocks at the bottom of the layout page form – Ankit Agrawal Oct 5 '13 at 16:42
  • Clearing cache didn't change anything, but Neo's updated answer is explaining why. – user11153 Oct 5 '13 at 16:54

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.