You are here

public function InsertView::tips in Advanced Insert View 2.0.x

Same name and namespace in other branches
  1. 8 src/Plugin/Filter/InsertView.php \Drupal\insert_view_adv\Plugin\Filter\InsertView::tips()

Generates a filter's tip.

A filter's tips should be informative and to the point. Short tips are preferably one-liners.

@todo Split into getSummaryItem() and buildGuidelines().

Parameters

bool $long: Whether this callback should return a short tip to display in a form (FALSE), or whether a more elaborate filter tips should be returned for template_preprocess_filter_tips() (TRUE).

Return value

string|null Translated text to display as a tip, or NULL if this filter has no tip.

Overrides FilterBase::tips

File

src/Plugin/Filter/InsertView.php, line 272

Class

InsertView
Provides a filter for insert view.

Namespace

Drupal\insert_view_adv\Plugin\Filter

Code

public function tips($long = FALSE) {
  if ($long) {
    $examples = [
      '[view:my_view]',
      '[view:my_view=my_display]',
      '[view:my_view=my_display=arg1/arg2/arg3]',
      '[view:my_view==arg1/arg2/arg3]',
    ];
    $items = [
      $this
        ->t('Insert view filter allows to embed views using tags. The tag syntax is relatively simple: [view:name=display=args]'),
      $this
        ->t('For example [view:tracker=page=1] says, embed a view named "tracker", use the "page" display, and supply the argument "1".'),
      $this
        ->t("The <em>display</em> and <em>args</em> parameters can be omitted. If the display is left empty, the view's default display is used."),
      $this
        ->t('Multiple arguments are separated with slash. The <em>args</em> format is the same as used in the URL (or view preview screen).'),
      [
        'data' => $this
          ->t('Valid examples'),
        'children' => $examples,
      ],
    ];
    $list = [
      '#type' => 'item_list',
      '#items' => $items,
    ];
    return render($list);
  }
  else {
    return $this
      ->t('You may use [view:<em>name=display=args</em>] tags to display views.');
  }
}