0

I am using QuickTabs to display, by year, a field-collection of a PDF and a Date. But I can't figure out how to send the argument from the QT to the contextual filter in the view because it is a block, not a page, so I don't have the arguments being submitted in the path to grab.

Here is my view without the contextual date filter, showing all the content (it is already being filtered by NID and type):

enter image description here

Here is a working, fixed-value contextual date filter:

enter image description here

This successfully filters the date to only 2017 items:

enter image description here

So, it is working with a fixed value. Now, trying to get it to use the argument from my QuickTabs is what isn't working. Here is my QuickTab (with the fixed contextual filter removed):

enter image description here

Here is what outputs on the tab WITHOUT the argument:

enter image description here

And here's the output on a tab with the argument (not working because there's no contextual filter anymore):

enter image description here

Seeings as how this isn't a block, I can't use the path arguments to the contextual filters. QuickTabs says "Additional arguments to send to the view as if they were part of the URL in the form of arg1/arg2/arg3. You may use %0, %1, ..., %N to grab arguments from the URL." I'm not totally sure how to use these but I tried using %0 as a fixed-value in the contextual filter. I've tried setting the argument in my quicktab to be "%0/%1/2017-01-01--2017-12-31". I've tried extensively using "Raw Value from URL" but no avail.

I've got all the modules enabled that I need to make this happen (i.e. date-views so that it accepts a range). So I'm sure it's just some very specific set of configuration and argument syntax that I just haven't guessed correctly yet.

Anyone able to help me with this issue has my sincerest thanks!!! Following is the view export:

$view = new view();
$view->name = 'resource_view';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'node';
$view->human_name = 'Resource View';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'Resource View';
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'some';
$handler->display->display_options['pager']['options']['items_per_page'] = '20';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['row_plugin'] = 'fields';
/* Relationship: Content: Resource (field_resource) */
$handler->display->display_options['relationships']['field_resource_value']['id'] = 'field_resource_value';
$handler->display->display_options['relationships']['field_resource_value']['table'] = 'field_data_field_resource';
$handler->display->display_options['relationships']['field_resource_value']['field'] = 'field_resource_value';
$handler->display->display_options['relationships']['field_resource_value']['delta'] = '-1';
/* Field: Field collection item: Resource Date */
$handler->display->display_options['fields']['field_resource_date']['id'] = 'field_resource_date';
$handler->display->display_options['fields']['field_resource_date']['table'] = 'field_data_field_resource_date';
$handler->display->display_options['fields']['field_resource_date']['field'] = 'field_resource_date';
$handler->display->display_options['fields']['field_resource_date']['relationship'] = 'field_resource_value';
$handler->display->display_options['fields']['field_resource_date']['label'] = '';
$handler->display->display_options['fields']['field_resource_date']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['field_resource_date']['settings'] = array(
  'format_type' => 'month_only',
  'fromto' => 'both',
  'multiple_number' => '',
  'multiple_from' => '',
  'multiple_to' => '',
  'show_remaining_days' => 0,
  'addtocalendar_show' => 0,
  'addtocalendar_settings' => array(
    'style' => 'blue',
    'display_text' => 'Add to Calender',
    'atc_title' => array(
      'field' => 'token',
      'tokenized' => '',
    ),
    'atc_description' => array(
      'field' => 'token',
      'tokenized' => '',
    ),
    'atc_location' => array(
      'field' => 'token',
      'tokenized' => '',
    ),
    'atc_organizer' => array(
      'field' => 'token',
      'tokenized' => '',
    ),
    'atc_organizer_email' => array(
      'field' => 'token',
      'tokenized' => '',
    ),
    'atc_date_end' => array(
      'field' => 'token',
      'tokenized' => '',
    ),
    'atc_privacy' => 'public',
    'data_secure' => 'auto',
    'data_calendars' => array(
      'iCalendar' => 0,
      'Google Calendar' => 0,
      'Outlook' => 0,
      'Outlook Online' => 0,
      'Yahoo! Calendar' => 0,
    ),
  ),
);
/* Field: Field collection item: Resource File */
$handler->display->display_options['fields']['field_resource_file']['id'] = 'field_resource_file';
$handler->display->display_options['fields']['field_resource_file']['table'] = 'field_data_field_resource_file';
$handler->display->display_options['fields']['field_resource_file']['field'] = 'field_resource_file';
$handler->display->display_options['fields']['field_resource_file']['relationship'] = 'field_resource_value';
$handler->display->display_options['fields']['field_resource_file']['label'] = '';
$handler->display->display_options['fields']['field_resource_file']['alter']['alter_text'] = TRUE;
$handler->display->display_options['fields']['field_resource_file']['alter']['text'] = 'Download to View';
$handler->display->display_options['fields']['field_resource_file']['alter']['make_link'] = TRUE;
$handler->display->display_options['fields']['field_resource_file']['alter']['path'] = '[field_resource_file]';
$handler->display->display_options['fields']['field_resource_file']['alter']['absolute'] = TRUE;
$handler->display->display_options['fields']['field_resource_file']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['field_resource_file']['click_sort_column'] = 'fid';
$handler->display->display_options['fields']['field_resource_file']['type'] = 'file_url_plain';
/* Contextual filter: Content: Nid */
$handler->display->display_options['arguments']['nid']['id'] = 'nid';
$handler->display->display_options['arguments']['nid']['table'] = 'node';
$handler->display->display_options['arguments']['nid']['field'] = 'nid';
$handler->display->display_options['arguments']['nid']['default_action'] = 'default';
$handler->display->display_options['arguments']['nid']['default_argument_type'] = 'fixed';
$handler->display->display_options['arguments']['nid']['default_argument_options']['argument'] = '6783';
$handler->display->display_options['arguments']['nid']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['nid']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['nid']['summary_options']['items_per_page'] = '25';
/* Filter criterion: Content: Published */
$handler->display->display_options['filters']['status']['id'] = 'status';
$handler->display->display_options['filters']['status']['table'] = 'node';
$handler->display->display_options['filters']['status']['field'] = 'status';
$handler->display->display_options['filters']['status']['value'] = 1;
$handler->display->display_options['filters']['status']['group'] = 1;
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
/* Filter criterion: Content: Type */
$handler->display->display_options['filters']['type']['id'] = 'type';
$handler->display->display_options['filters']['type']['table'] = 'node';
$handler->display->display_options['filters']['type']['field'] = 'type';
$handler->display->display_options['filters']['type']['value'] = array(
  'resource_page' => 'resource_page',
);

/* Display: View: Pedestrian Resources */
$handler = $view->new_display('block', 'View: Pedestrian Resources', 'block');
$handler->display->display_options['defaults']['fields'] = FALSE;
/* Field: Field collection item: Resource Date */
$handler->display->display_options['fields']['field_resource_date_1']['id'] = 'field_resource_date_1';
$handler->display->display_options['fields']['field_resource_date_1']['table'] = 'field_data_field_resource_date';
$handler->display->display_options['fields']['field_resource_date_1']['field'] = 'field_resource_date';
$handler->display->display_options['fields']['field_resource_date_1']['relationship'] = 'field_resource_value';
$handler->display->display_options['fields']['field_resource_date_1']['settings'] = array(
  'format_type' => 'date_only_full',
  'fromto' => 'both',
  'multiple_number' => '',
  'multiple_from' => '',
  'multiple_to' => '',
  'show_remaining_days' => 0,
  'addtocalendar_show' => 0,
  'addtocalendar_settings' => array(
    'style' => 'blue',
    'display_text' => 'Add to Calender',
    'atc_title' => array(
      'field' => 'token',
      'tokenized' => '',
    ),
    'atc_description' => array(
      'field' => 'token',
      'tokenized' => '',
    ),
    'atc_location' => array(
      'field' => 'token',
      'tokenized' => '',
    ),
    'atc_organizer' => array(
      'field' => 'token',
      'tokenized' => '',
    ),
    'atc_organizer_email' => array(
      'field' => 'token',
      'tokenized' => '',
    ),
    'atc_date_end' => array(
      'field' => 'token',
      'tokenized' => '',
    ),
    'atc_privacy' => 'public',
    'data_secure' => 'auto',
    'data_calendars' => array(
      'iCalendar' => 0,
      'Google Calendar' => 0,
      'Outlook' => 0,
      'Outlook Online' => 0,
      'Yahoo! Calendar' => 0,
    ),
  ),
);
/* Field: Field collection item: Resource File */
$handler->display->display_options['fields']['field_resource_file']['id'] = 'field_resource_file';
$handler->display->display_options['fields']['field_resource_file']['table'] = 'field_data_field_resource_file';
$handler->display->display_options['fields']['field_resource_file']['field'] = 'field_resource_file';
$handler->display->display_options['fields']['field_resource_file']['relationship'] = 'field_resource_value';
$handler->display->display_options['fields']['field_resource_file']['label'] = '';
$handler->display->display_options['fields']['field_resource_file']['alter']['alter_text'] = TRUE;
$handler->display->display_options['fields']['field_resource_file']['alter']['text'] = 'Download to View';
$handler->display->display_options['fields']['field_resource_file']['alter']['make_link'] = TRUE;
$handler->display->display_options['fields']['field_resource_file']['alter']['path'] = '[field_resource_file]';
$handler->display->display_options['fields']['field_resource_file']['alter']['absolute'] = TRUE;
$handler->display->display_options['fields']['field_resource_file']['alter']['target'] = '_blank';
$handler->display->display_options['fields']['field_resource_file']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['field_resource_file']['click_sort_column'] = 'fid';
$handler->display->display_options['fields']['field_resource_file']['type'] = 'file_url_plain';
$handler->display->display_options['defaults']['arguments'] = FALSE;
/* Contextual filter: Content: Nid */
$handler->display->display_options['arguments']['nid']['id'] = 'nid';
$handler->display->display_options['arguments']['nid']['table'] = 'node';
$handler->display->display_options['arguments']['nid']['field'] = 'nid';
$handler->display->display_options['arguments']['nid']['default_action'] = 'default';
$handler->display->display_options['arguments']['nid']['default_argument_type'] = 'fixed';
$handler->display->display_options['arguments']['nid']['default_argument_options']['argument'] = '6781';
$handler->display->display_options['arguments']['nid']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['nid']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['nid']['summary_options']['items_per_page'] = '25';
$handler->display->display_options['block_description'] = 'View: Pedestrian Resource View';

/* Display: View: Monthly Indicator Resources */
$handler = $view->new_display('block', 'View: Monthly Indicator Resources', 'block_1');
$handler->display->display_options['defaults']['arguments'] = FALSE;
/* Contextual filter: Content: Nid */
$handler->display->display_options['arguments']['nid']['id'] = 'nid';
$handler->display->display_options['arguments']['nid']['table'] = 'node';
$handler->display->display_options['arguments']['nid']['field'] = 'nid';
$handler->display->display_options['arguments']['nid']['default_action'] = 'default';
$handler->display->display_options['arguments']['nid']['default_argument_type'] = 'fixed';
$handler->display->display_options['arguments']['nid']['default_argument_options']['argument'] = '6783';
$handler->display->display_options['arguments']['nid']['summary']['number_of_records'] = '0';
$handler->display->display_options['arguments']['nid']['summary']['format'] = 'default_summary';
$handler->display->display_options['arguments']['nid']['summary_options']['items_per_page'] = '25';
$handler->display->display_options['block_description'] = 'View: Monthly Indicator Resource View';

////////////////////

UPDATE IN RESPONSE TO Stefanos-Petrakis

////////////////////

I've tried it your way but the contextual filter just filters everything out.

enter image description here

Here's the field settings:

enter image description here

enter image description here

As you can see, it takes out everything...

enter image description here enter image description here

The date field takes Year and Month only, not that it should matter. Other than that, it is a normal date field. Definitely have dates in 2016, as well.

enter image description here

I'd be happy to provide any other screenshots that may be helpful. Thank you so much.

/////////////////////

1
+50

You don't need any coding for this, you should simply activate the date_views submodule (comes with the Date module).

After you do that, your contextual filters will include some useful choices, namely the granularity one:

enter image description here

Setting up your contextual filter like that, should already make it possible, inside Views admin, to test your contextual filter:

enter image description here Once this is working as expected, you simply need to pass the year argument to your quicktab:

enter image description here

Your QT-block now can filter by year tab:

(example for 2017) enter image description here

(example for 2016) enter image description here

Good luck!

  • I tried it your way and it didn't work, unfortunately. I updated my original question to show what happened with your suggestion. You can search for "UPDATE IN RESPONSE TO Stefanos-Petrakis" to find it quickly on the page. Thank you so much for trying to help fix this. – ProGrammar Apr 4 '17 at 14:39
  • You seem to have two contextual filters in your view: In that case (inside the Views admin interface, in the preview area) you should input sth like NID/DATE e.g. 1/2016 Otherwise, simply entering 2016 will not be mapped to the right contextual filter (order counts). – Stefanos Petrakis Apr 4 '17 at 15:14
  • That was it! Now it works! My NID filter was a fixed value, so I didn't think I needed to pass it as an argument. So I changed it to be similar to this and used 1234/2017, 1234/2016, 1234/2015, etc. and it worked! Thanks so much! I can award you the bounty in 2 hrs. – ProGrammar Apr 4 '17 at 15:27
-1

Use

views_embed_view():
views_embed_view('view_machine_name', 'block_1');
views_embed_view('view_machine_name', 'block_1', $param);

if you want to pass a parameter to the view.

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.