Hi,

I have panels 2 and panels tabs installed. I have successfully created a tabbed panel page that has tabs for a couple of views I made. If I go to www.mydomain.com/mypanel/arg1, I want it to display the panel and pass arg1 to each of the views. However this does not appear to be working.

Can you tell me what I have to do to pass that argument to the views? I have the views setup as pages and blocks to try and get it working. If I go to the view's page directly, I can limit the display by the argument. However on the panels page it displays everything for that view and does not limit by the argument.

Any ideas?

Comments

merlinofchaos’s picture

Status: Active » Fixed

Drupal's blocks cannot accept arguments.

You have to use either the panels views or panels legacy views module, both of which have solutions for this problem.

rgraves’s picture

Thanks. Can you explain how the panels solution can solve the problem? I'm trying to use panels to accomplish this but it is not limiting the view according the the argument I give.

Rob

rgraves’s picture

I don't understand why the arguments aren't working in Panels 2. I have a view setup that displays a series of nodes. It accepts an argument (a taxonomy term) which then only displays the nodes with that term associated with them.

If I go to the view directly, it filters the nodes properly if there's an argument present. When I put the view within a panel, the argument does nothing.

Now to make it more confusing, if I edit the view and hardcode the arugment in the argument handling code, the view works properly in the panel.

Example of code in argument handling code:

$args[0] = "english";
return $args;

Any idea how to fix this so that an argument in the URL of the panel is passed down to the view?

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

SergeyK’s picture

I am completely lost, too, in the matter of passing argument from Panel Pages to my Panel View. I've setup and tested sweetly in View Page mode a simple block view called "Tag" with argument = Taxonomy: Term ID. This View displays certain nodes from the "Tag" free-tagging vocabulary. Than I've wrapper my "Tag" View with Panel View also called "Tag" with Argument source: = "From panel argument| and Panel argument: = "First". Finally, I create a Panel Page called also "Tag" with Path: = taxonomy/term (or taxonomy/term/% - I've tested a bunch of cases, and not only with Path:). In Context -> Arguments of my "Tag" Panel Page I select "Taxonomy term", and than set up Argument type: to "Term ID". Also I check my "Tag" Vocabulary on the "Taxonomy term" option pane. That's it!

The last step is adding "Tag" Panel View to the Panel Page and testing it with normally working URLs like taxonomy/term/tid. Two types of behaviour are possible on this stage: "Tag" Panel View displays either nothing or all of my content, either grouped by Summary type defined in Views argument configuration, or just a simple list View. What is surprising that Panel Page displays taxonomy term name in it's header, but it seems that this argument is not passed to the Panel View -> View. What am I doing wrong?

merlinofchaos’s picture

Status: Closed (fixed) » Active

There are at least 3 different ways to get a view into a panel.

Unless you describe to me *precisely* the method you're using, all that's going to happen is that your wheels will spin and I will get mad at you. And by precisely I mean step by step...which module you're using, which admin page you're doing it with, and exactly which content item in which category you're adding to your view.

SergeyK’s picture

My aim is to replace the default /taxonomy/term/tid page with Panel Page, containing, among other panes, a View, that will list nodes with tid. I have Panels, Views, Panel Pages and Views Panes modules enabled. I have also a free-tagging vocabulary named Tag, populated with tax terms.

First, I create a View.

  $view = new stdClass();
  $view->name = 'Tag';
  $view->description = '';
  $view->access = array (
);
  $view->view_args_php = '';
  $view->page = FALSE;
  $view->page_title = '';
  $view->page_header = '';
  $view->page_header_format = '1';
  $view->page_footer = '';
  $view->page_footer_format = '1';
  $view->page_empty = '';
  $view->page_empty_format = '1';
  $view->page_type = 'list';
  $view->url = 'taxonomy/term';
  $view->use_pager = TRUE;
  $view->nodes_per_page = '10';
  $view->block = TRUE;
  $view->block_title = 'Wire';
  $view->block_header = '';
  $view->block_header_format = '1';
  $view->block_footer = '';
  $view->block_footer_format = '1';
  $view->block_empty = '';
  $view->block_empty_format = '1';
  $view->block_type = 'list';
  $view->nodes_per_block = '5';
  $view->block_more = FALSE;
  $view->block_use_page_header = FALSE;
  $view->block_use_page_footer = FALSE;
  $view->block_use_page_empty = FALSE;
  $view->sort = array (
    array (
      'tablename' => 'node',
      'field' => 'created',
      'sortorder' => 'DESC',
      'options' => 'normal',
    ),
  );
  $view->argument = array (
    array (
      'type' => 'taxid',
      'argdefault' => '2',
      'title' => '',
      'options' => '',
      'wildcard' => '',
      'wildcard_substitution' => '',
    ),
  );
  $view->field = array (
    array (
      'tablename' => 'node',
      'field' => 'title',
      'label' => '',
      'handler' => 'views_handler_field_nodelink',
      'options' => 'link',
    ),
    array (
      'tablename' => 'node_comment_statistics',
      'field' => 'comment_count',
      'label' => '',
      'handler' => 'views_handler_field_int',
    ),
    array (
      'tablename' => 'node_data_field_teaser_image',
      'field' => 'field_teaser_image_value',
      'label' => '',
      'handler' => 'content_views_field_handler_group',
      'options' => 'default',
    ),
    array (
      'tablename' => 'node',
      'field' => 'created',
      'label' => '',
      'handler' => 'views_handler_field_date_custom',
      'options' => 'M j',
    ),
    array (
      'tablename' => 'users',
      'field' => 'name',
      'label' => 'by',
    ),
    array (
      'tablename' => 'node_data_field_lead',
      'field' => 'field_lead_value',
      'label' => '',
      'handler' => 'content_views_field_handler_group',
      'options' => 'default',
    ),
    array (
      'tablename' => 'node',
      'field' => 'view',
      'label' => '',
      'options' => 'more',
    ),
  );
  $view->filter = array (
    array (
      'tablename' => 'node',
      'field' => 'status',
      'operator' => '=',
      'options' => '',
      'value' => '1',
    ),
  );
  $view->exposed_filter = array (
  );
  $view->requires = array(node, node_comment_statistics, node_data_field_teaser_image, users, node_data_field_lead);
  $views[$view->name] = $view;

2nd step: I create a Views Pane from my original View. Here is a code for my Views Pane:

$panel_view = new stdClass();
  $panel_view->pvid = 'new';
  $panel_view->view = 'Tag';
  $panel_view->name = 'Tag';
  $panel_view->description = '';
  $panel_view->title = 'Tag';
  $panel_view->category = 'Views';
  $panel_view->category_weight = '-1';
  $panel_view->view_type = 'block';
  $panel_view->use_pager = '1';
  $panel_view->pager_id = '1';
  $panel_view->nodes_per_page = '5';
  $panel_view->offset = '0';
  $panel_view->link_to_view = '0';
  $panel_view->more_link = '0';
  $panel_view->feed_icons = '1';
  $panel_view->url_override = '0';
  $panel_view->url = '';
  $panel_view->url_from_panel = '0';
  $panel_view->contexts = array (
    0 => 
    array (
      'type' => 'panel',
      'context' => 'any',
      'panel' => '0',
      'fixed' => 'CeBIT',
      'label' => 'Taxonomy: Term Name',
    ),
  );
  $panel_view->allow_type = '0';
  $panel_view->allow_nodes_per_page = '1';
  $panel_view->allow_offset = '0';
  $panel_view->allow_use_pager = '1';
  $panel_view->allow_link_to_view = '0';
  $panel_view->allow_more_link = '0';
  $panel_view->allow_feed_icons = '0';
  $panel_view->allow_url_override = '0';
  $panel_view->allow_url_from_panel = '0';

And the final step is adding my Views Pane to a Panel Page. Exported code looks like this:

$page = new stdClass();
$page->pid = 'new';
  $page->name = 'Tag';
  $page->title = '';
  $page->arguments = array (
    0 => 
    array (
      'name' => 'term',
      'default' => 'ignore',
      'title' => 'Tag: %term',
      'id' => 1,
      'identifier' => 'Taxonomy term',
      'keyword' => 'term',
      'argument_settings' => 
      array (
        'input_form' => 'tid',
        'vids' => 
        array (
          3 => 0,
          1 => 0,
          2 => 0,
        ),
        'own_default' => 0,
        'displays' => 
        array (
          1 => 0,
          2 => 0,
          3 => 0,
        ),
      ),
    ),
  );
  $page->contexts = array();
  $page->relationships = array();
  $page->access = array();
  $page->path = 'taxonomy/term';
  $page->css_id = '';
  $page->css = '';
  $page->no_blocks = '0';
  $page->menu = '0';
  $page->menu_tab = '0';
  $page->menu_tab_weight = '0';
  $page->menu_title = '';
  $page->menu_tab_default = '0';
  $page->menu_tab_default_parent_type = 'tab';
  $page->menu_parent_title = '';
  $page->menu_parent_tab_weight = '0';
$display = new stdClass();
$display->did = 'new';
$display->name = NULL;
$display->layout = 'flexible';
$display->layout_settings = array (
  'width_type' => 'px',
  'percent_width' => '645',
  'rows' => '3',
  'row_1' => 
  array (
    'columns' => '1',
    'width_1' => '645',
    'names' => 
    array (
      0 => 'Top',
    ),
  ),
  'row_2' => 
  array (
    'columns' => '2',
    'width_1' => '380',
    'width_2' => '230',
    'names' => 
    array (
      0 => 'Left',
      1 => 'Right',
    ),
  ),
  'row_3' => 
  array (
    'columns' => '1',
    'width_1' => '645',
    'names' => 
    array (
      0 => 'Bottom',
    ),
  ),
  'sidebars' => 
  array (
    'left' => 0,
    'left_width' => 200,
    'right' => 1,
    'right_width' => '350',
    'width_type' => 'px',
  ),
);
$display->panel_settings = array (
  'style' => 'default',
  'style_settings' => 
  array (
  ),
  'edit_style' => 'Edit style settings',
  'individual' => 0,
  'panel' => 
  array (
    'sidebar_right' => 
    array (
      'style' => '',
      'edit_style' => 'Edit style settings',
    ),
    'row_1_1' => 
    array (
      'style' => '',
      'edit_style' => 'Edit style settings',
    ),
    'row_2_1' => 
    array (
      'style' => '',
      'edit_style' => 'Edit style settings',
    ),
    'row_2_2' => 
    array (
      'style' => '',
      'edit_style' => 'Edit style settings',
    ),
    'row_3_1' => 
    array (
      'style' => '',
      'edit_style' => 'Edit style settings',
    ),
  ),
  'did' => '12',
);
$display->content = array();
$display->panels = array();
$pane = new stdClass();
  $pane->pid = 'new-1';
  $pane->panel = 'row_1_1';
  $pane->type = 'views2';
  $pane->subtype = 'Tag';
  $pane->access = array();
  $pane->configuration = array (
    'override_title' => 0,
    'override_title_text' => '',
    'css_id' => '',
    'css_class' => '',
    'title' => 'Tag',
    'name' => 'Tag',
    'arguments' => 
    array (
      0 => '',
    ),
    'use_pager' => 1,
    'pager_id' => '1',
    'nodes_per_page' => '5',
  );
$display->content['new-1'] = $pane;
$display->panels['row_1_1'][0] = 'new-1';
$pane = new stdClass();
  $pane->pid = 'new-2';
  $pane->panel = 'row_2_1';
  $pane->type = 'block';
  $pane->subtype = 'views-Insiders';
  $pane->access = array();
  $pane->configuration = array (
    'override_title' => 0,
    'override_title_text' => '',
    'css_id' => '',
    'css_class' => '',
    'module' => 'views',
    'delta' => 'Insiders',
    'block_visibility' => 0,
  );
$display->content['new-2'] = $pane;
$display->panels['row_2_1'][0] = 'new-2';
$pane = new stdClass();
  $pane->pid = 'new-3';
  $pane->panel = 'sidebar_right';
  $pane->type = 'block';
  $pane->subtype = 'views-Markets';
  $pane->access = array();
  $pane->configuration = array (
    'override_title' => 0,
    'override_title_text' => '',
    'css_id' => '',
    'css_class' => '',
    'module' => 'views',
    'delta' => 'Markets',
    'block_visibility' => 0,
  );
$display->content['new-3'] = $pane;
$display->panels['sidebar_right'][0] = 'new-3';
$pane = new stdClass();
  $pane->pid = 'new-4';
  $pane->panel = 'sidebar_right';
  $pane->type = 'panels_mini';
  $pane->subtype = 'Highlights';
  $pane->access = array();
  $pane->configuration = array (
    'override_title' => 0,
    'override_title_text' => '',
    'css_id' => '',
    'css_class' => '',
    'name' => 'Highlights',
  );
$display->content['new-4'] = $pane;
$display->panels['sidebar_right'][1] = 'new-4';
$pane = new stdClass();
  $pane->pid = 'new-5';
  $pane->panel = 'sidebar_right';
  $pane->type = 'block';
  $pane->subtype = 'views-Research';
  $pane->access = array();
  $pane->configuration = array (
    'override_title' => 0,
    'override_title_text' => '',
    'css_id' => '',
    'css_class' => '',
    'module' => 'views',
    'delta' => 'Research',
    'block_visibility' => 0,
  );
$display->content['new-5'] = $pane;
$display->panels['sidebar_right'][2] = 'new-5';
$page->display = $display;
$page->displays = array();

Finally, when I type in my browser www.mysite.com/taxonomy/term/1, Views Pane lists all my node, not filtered by any argument or whatsoever. What am I doing wrong? Thanks in advance for your answer, Merlinofchaos!

merlinofchaos’s picture

In your panel view setup, you should change 'From argument' to 'From context', and then set the required context type to taxonomy term.

SergeyK’s picture

I did this but the Pane still shows unfiltered nodes, seems it doesn't catch the argument ((

merlinofchaos’s picture

Once you do that you'll then need to go and edit the configuration on the pane, then click save. That'll make sure the context is set properly.

SergeyK’s picture

For sure, I remove/then add again panes many times, saving em each time. May be my problem in other parameters?

sdboyer’s picture

Status: Active » Fixed

Hi SergeyK,

I tried to replicate the error you've described using the exported data you provided. I've come to three conclusions:

  1. There was a bug in the panels_views.module that was preventing panels arguments from being passed to views.
  2. HOWEVER, I was only able to get that bug to occur when the panel view was setup to receive its argument 'From Argument' rather than 'From Context,' which is the change that merlin asked you to make in #8. Are you sure you changed that setting correctly? Once I switched it, the panel view started filtering according to taxonomy properly.
  3. The issue causing the bug in #1 has already been fixed in -dev, and will be solved as of beta3.
Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

greg.harvey’s picture

But nothing would stop this from working in your own hook_block?

  $some_arg = 'foo';

...

  if ($op == 'view') {
    $block = array();

    switch ($delta) {
      case 0:
        $block['subject'] = t('My view block');
        $block['content'] = views_embed_view('my_view_name', 'block', $some_arg);
        return $block;
      }
    }
shv_rk’s picture

Hello,

I have the same problem please help me...
druapal 6, IIS6, no clean urls

here is my situation:
basically, i want to create a normal page but at the bottom it should list all my ingredients.
next to my list I want to have a links as: A-e E-F and so on to filter my list when the user clicks on it.
here is what i have done:
I have created a content type: ingredients
I have created a taxonomy vocabulary with A-e E-F ... terms
I have created a views to list all my gradients
i have created the my view as a block
set the view argument as:
taxonomy: term
Action to take if argument is not present: > phpcode:
$path = drupal_get_path_alias( $_GET["q"]);
$path = explode("/", $path);
return $path[1];

Action to take if argument does not validate: Display All Values

when I click on my A-e link for example with this url: index.php?q=ingredients/A-E
i get 404 page

if I return "A-E" works fine...

am I missing something? please help me...

sh

gulzi’s picture

thumbs up! good work, greg.harvey