Overview

Passing an argument from the URL into a block is a common thing. The idea is that the content of a block will change according to what is viewed. For example, we would like a block to show us all the taxonomy terms of a certain node. For this reason we need to pass to the block the argument of the node id (nid). In the following url http://xxx/node/123 argument number 1, which we will call %1, and is equal to 123.

When creating a mini panel, you get the functionality of Panel pages, but the outcome is a block that can be either configured through the blocks admin (http://xxx/admin/build/block), or added to a panel page.

Modules

  • Panels
  • Panel pages
  • Mini panels
  • Views

Requirements

  • Create a mini panel that shows the comments the currently signed-in user has written in the currently viewed page.
  • Enable the block on nodes.

Operation

  1. Create a view according to the requirement- user_comments_per_node. (Example attached at bottom of page.)
  2. We need to prepare the integration of our view 'user_comments_per_node' with panels.
    1. Go to Admin, Panels, Views, or http://xxx/admin/panels/views.
    2. Select the view from the dropdown list and click create panel view
  3. In the view Select our View - user_comments_per_node.
    1. Set the Panel view title to: User comments per node
    2. Keep the view type as block, since we defined there this should appear as 'List'.
    3. Set the required context to: Node
    4. Set the amount of items to display to five (5).
    5. Click 'Save'.
  4. Just to understand what's going in this page:
    1. 'Basic information' concerns the Visual representation of the Views in the panel admin.
    2. 'Arguments' defines which argument the view can and is allowed to get. Since panel can have several context it's important to make sure the views gets the correct arguments.
    3. 'Paging information' defines whether the output of the views should be paged (i.e. those | 1 | 2 | next>> | Last | links ). Even if paging wasn't defined in the views, it can be defined here. Also the number of posts or offset (i.e. output the view starting from the 2nd result).
    4. 'Pane decorations' are Merlin's way of letting us, grateful people, decide if the panel will allow us to override few settings from the panel itself. This can become handy if you have several pages showing the same views, but need a slightly different behavior.
  5. Add a mini-panel by going to Panels -> Mini Panels, or http://xxx/admin/ panels/panel-mini/add.
  6. Set the layout as 'Single column'.
  7. Enter the mini panel title and name. Set the title to 'My comments' and the name to 'user_comments'. Click 'Next'.
  8. We've been redirected to the 'Content' tab – here we will add the View created previously.
  9. Click on the 'Add content' Icon and select under 'Views' our view. Click 'Add pane'.
  10. Our view was added. Don't forget to save the panel; just adding it is not enough.
  11. The mini panel is ready, which means that in the blocks admin (http://xxx/admin/build/block) we have a new mini-panel called Mini panel: "My comments". Set it to appear on the 'Right sidebar'.
  12. How to show the block only on certain content types, and in another place? Use the panel pages node override of course. Here's a tutorial for getting started with node overrides.

If you want to import a starting point, download the code and import it by clicking the import tab at the top of the Panel pages module.

As an example View, you can start with this export. (This may not exactly meet the initial specifications, but it does pick up comments for a particular node only.) Import the view using the Import tab under the Views UI.