1

I want to display a gallery with the FlexSlider formatter in a Body field.

I installed the Token and Token filter modules and enabled "token filter" in text formats (admin/config/content/formats).

On my content type (admin/structure/types/manage/[content_type]/display) I enabled the "Token" display mode in "Extended display parameters".

For the Token display mode (admin/structure/types/manage/[content_type]/display/token) I set the FlexSlider formatter for my image field (field_gallery).

I added a node with the [node:field_gallery] token in the Body field but the token is being replaced with nothing.

How can I make an image field using the flex slider field formatter work with the token filter module?

  • 1
    You stated a fact. Please edit it to give it a form of a question. – Mołot Nov 14 '14 at 8:29
1

My solution.

Install custom_formatters module.

Create a view with FlexSlider formatter:

    $view = new view();
    $view->name = 'field_slider';
    $view->description = '';
    $view->tag = 'default';
    $view->base_table = 'node';
    $view->human_name = 'Slider';
    $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['use_more_always'] = FALSE;
    $handler->display->display_options['use_more_text'] = 'more';
    $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['exposed_form']['options']['submit_button'] = 'Apply';
    $handler->display->display_options['exposed_form']['options']['reset_button_label'] = 'Reset';
    $handler->display->display_options['exposed_form']['options']['exposed_sorts_label'] = 'Sort by';
    $handler->display->display_options['exposed_form']['options']['sort_asc_label'] = 'Asc';
    $handler->display->display_options['exposed_form']['options']['sort_desc_label'] = 'Desc';
    $handler->display->display_options['pager']['type'] = 'full';
    $handler->display->display_options['pager']['options']['expose']['items_per_page_label'] = 'Elements';
    $handler->display->display_options['pager']['options']['expose']['items_per_page_options_all_label'] = '- All -';
    $handler->display->display_options['pager']['options']['expose']['offset_label'] = 'Skip';
    $handler->display->display_options['pager']['options']['tags']['first'] = '« first';
    $handler->display->display_options['pager']['options']['tags']['previous'] = '‹ prev';
    $handler->display->display_options['pager']['options']['tags']['next'] = 'next›';
    $handler->display->display_options['pager']['options']['tags']['last'] = 'last»';
    $handler->display->display_options['style_plugin'] = 'flexslider';
    $handler->display->display_options['style_options']['optionset'] = 'gallery_in_text';
    $handler->display->display_options['row_plugin'] = 'fields';
    /*  */
    $handler->display->display_options['fields']['field_gal']['id'] = 'field_gal';
    $handler->display->display_options['fields']['field_gal']['table'] = 'field_data_field_gal';
    $handler->display->display_options['fields']['field_gal']['field'] = 'field_gal';
    $handler->display->display_options['fields']['field_gal']['label'] = '';
    $handler->display->display_options['fields']['field_gal']['element_label_colon'] = FALSE;
    $handler->display->display_options['fields']['field_gal']['click_sort_column'] = 'fid';
    $handler->display->display_options['fields']['field_gal']['settings'] = array(
      'image_style' => '',
      'image_link' => '',
    );
    $handler->display->display_options['fields']['field_gal']['group_rows'] = FALSE;
    $handler->display->display_options['fields']['field_gal']['delta_offset'] = '0';
    /*  */
    $handler->display->display_options['sorts']['created']['id'] = 'created';
    $handler->display->display_options['sorts']['created']['table'] = 'node';
    $handler->display->display_options['sorts']['created']['field'] = 'created';
    $handler->display->display_options['sorts']['created']['order'] = 'DESC';
    /*  */
    $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'] = 'not found';
    $handler->display->display_options['arguments']['nid']['exception']['title'] = 'All';
    $handler->display->display_options['arguments']['nid']['default_argument_type'] = 'fixed';
    $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['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;
    /*  */
    $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(
      'page' => 'page',
    );

Go to the custom formatters settings, create new formatter for Image field: Format: PHP Field types: Image Formetter (php):

  print views_embed_view('field_slider','default', $variables['#object']->nid);

Or import this:

    $formatter = new stdClass();
    $formatter->disabled = FALSE; /* Edit this to true to make a default formatter disabled initially */
    $formatter->api_version = 2;
    $formatter->name = 'gallery_views';
    $formatter->label = 'Gallery views';
    $formatter->description = '';
    $formatter->mode = 'php';
    $formatter->field_types = 'image';
    $formatter->code = 'print views_embed_view(\'field_slider\',\'default\', $variables[\'#object\']->nid);';
    $formatter->fapi = '';

Then go to the Token tab (admin/structure/types/manage/[your_content_type]/display/token), set the Gallery views formatter. Now it works.

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.