Passing Arguments to views inside panel

Events happening in the community are now at Drupal community events on www.drupal.org.
avior's picture

Hi There
I have been using panles 2 beta 2, with views 1.6

I want to be able to pass the panel page argument to the views inside the panel ,
I have read all the documentation here, but can't make this happen, any help will be appreciated.

I have a content type call event (with a date field called date_start)
I have set up a view called events that accept the date_start as an argument, (it's the second argument , the first is termid, and the third is RSS: RSS Feed Selector)
the view has argument code that set up the default value

when i run the the view and pass this parameters - everythig work's fine

I have set up a panel view kids_events_2 and set up the arguments (termid is fixed ) ,
about the date, and rss i have tried all the options : from context, from panel argument, input from panel but none worked

I have set up a panel page PanelEvents, and tried to set up the panel arguments, and tried without arguments
I want that the argument sent to the panel will be passed to the views
so is i write ...PanelEvents/DATE_FILTER_HERE i.e. PanelEvents/@P2W the "@P2W" will be passed to the view

I am missing something here, any help will be appreciated

I am attaching the view , panel view & panel

Thanks in advance
Avior

AttachmentSize
panel-views.txt5.89 KB

Comments

argument handling code

yhager's picture

I am not sure how panels2 handles arguments, but I guess you can always handle it using the argument handling code within the view. It's not so elegant, but I think it would work..

Part Solution

avior's picture

I have managed to do this

The only way i have managed to do it, set the panel view parameters as "input on pane config"
and leave it empty in the panel pane config

view setting :
set the arguments to the view (i have set 3 : termid, date, rss feed)
check the arguments send in the url and set the view argument

if ($view->build_type == 'block' && arg(1) ) {
  $args[1] = arg(1);
} elseif (!$args[1]) {
     $args[1] = "@P1W"; // filter the events for the next week only
}
$view->is_cacheable = 0;
return $args;

this small code helped me debug the view arguments , set the header to

<?php

print '<div align="left">';
print
'<br/>arg-0 :' .arg(0);
print
'<br/>arg-1 :' .arg(1);
print
'<br/>arg-2 :' .arg(2);
print
'<br/>q:' . $_GET['q'];

$view = $GLOBALS['current_view'];
$args = $view->args;

print
'<br/>args-0 :' .$args[0];
print
'<br/>args-1 :' .$args[1];

print
'</div>';

?>

hope this will help someone

Avior

Thats was great, thanks a

anunez's picture

Thats was great, thanks a lot. This small piece of header debug code should be stardard in panels-views.. I was wasting time assuming wrong arg index while creating a variant of node-add because of 'add' was included automagically in the url. Thanks!

just what I was looking for

bdimaggio's picture

Hey Avior -- This was a huge help. Thanks!
Ben

dman's picture

Yeah, thanks for this.

My case is:
I have a node type "Topic Overview" This provides a summary of each topic (term). I'm playing with NAT to see if I can get the relationships straightened out, but anyway...

The 'topic overview' page contains a set of blocks - list of all 'documents' tagged with the same term, list of all 'events' tagged with the same term, etc. Not bothering with panels yet. Maybe...

I created a view-block to list all documents, filtered by node type.
I added Argument Taxonomy: Term ID (with depth) and limited it to my target vocabulary ("Topics")
So my block takes the arg (Term ID) and gives me my filtered list.

Now - to pass the arg in when the block is embedded in the page, I followed the above instructions to end up with:

<?php
# When this block is embedded in a node, we need to find the appropriate term to list.
# detect the term node ID from context.
# find the associated term ID
# use that
# http://geeksandgod.com/tutorials/computers/cms/drupal/limit-views-create...
# http://groups.drupal.org/node/9770

# is it a node page? (also use block visibility to limit this display)
if (arg(0) == 'node' && arg(1) ) {
 
$node = node_load(arg(1));
 
# Now find the topic ID of this node. Filter by vocab 'Topic'
 
$topic_vocab_id = 2;
 
# This ID is custom to my setup : "Topics":vid=2

  # Could have scanned the node, but this is quicker code.
 
$tids = taxonomy_node_get_terms_by_vocabulary($node, $topic_vocab_id);

 
# assume just one... it's possible to concat more, I guess.
 
$term = array_pop($tids);
 
# this is the arg to this view.
 
$args[1] =  $term->tid;
  return
$term->tid;
}
return
'';
?>

in my Provide default argument options

Good so far. Needs some error checking probably.

That is a nice little piece

frob's picture

That is a nice little piece of code.

Moncler Coats and Jackets

happyday123's picture

moncler milano maybe go with one accession with anybody heat. Buckskin vests

Panels

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: