Example scenario:
There is a panel containing View Content Pane.
Panel URL: /panel_url
Example with argument: /panel_url/term_name
With BEF: /panel_url?category=123
How to set up (having existing panel and added Content Pane):
- Add Contextual filter to the View.
E.g.: Views contextual filters taxonomy name
- Change settings in 'View -> Pane settings -> Argument input' to load the argument 'From panel argument' (e.g. First).
Done.
In addition, if you're using Better Exposed Filters, you could do the following improvements.
To set the current active link based on the argument (if you're using select_as_links):
/**
* Implements hook_preprocess_[themeFunctionName]().
*/
function foo_preprocess_select_as_links(&$variables) {
$options = isset($variables['element']['#options']) ? array_change_key_case(array_flip($variables['element']['#options']), CASE_LOWER) : array();
$selected = end((arg()));
if (array_key_exists($selected, $options)) {
$variables['element']['#value'] = $options[$selected];
}
}
To set the current active link based on the argument (if you're using select):
/**
* Implements hook_preprocess_[themeFunctionName]().
*/
function foo_preprocess_select(&$variables) {
switch (arg(0)) {
case 'panel_url':
if (@$variables['element']['#name'] == 'DROPDOWN_NAME') { // name of your select list
$options = isset($variables['element']['#options']) ? array_change_key_case(array_flip($variables['element']['#options']), CASE_LOWER) : array();
$selected = end((arg()));
if (array_key_exists($selected, $options)) {
if ($variables['element']['#value'] <> $options[$selected]) {
$variables['element']['#value'] = $options[$selected];
} else {
// drupal_goto('panel_url');
}
}
}
break;
}
}
To make the links SEO friendly, you can try something like:
/**
* Implements hook_url_inbound_alter().
*/
function foo_url_outbound_alter(&$path, &$options, $original_path){
if (arg(0) == 'panel_url') {
// Convert URL like: /panel_url?category=29 into /panel_url/term_name (SEO friendly)
$path_info = parse_url($path);
switch (@$path_info['path']) {
case 'panel_url/term_name':
case 'panel_url/term_name2':
$path = 'panel_url/all'; // Convert loopy urls into base url
}
if (strpos($path, '?category=') !== FALSE) { // Convert term id into human name
list(, $tid) = explode('=', current(explode('&', $path_info['query']))); // get tid from URL
$term_name = strtolower(taxonomy_term_load((int)$tid)->name);
$path = '/panel_url' . '/' . $term_name; // See also: $path_info['path']
}
}
}