Add a display to a view

You can add one or more displays to a view. Each display is a variation of the view. For example, you could start with a view that shows a page of recently modified content and then create new displays to output the same content as a block and as a feed. A display can also be modified to override any of the view parameters.

Comparison of PHPTemplate and Twig theming paradigms

This page compares PHPTemplate to Twig. The Twig effort is currently in progress, so there will be changes and additions to this doc.

For more information, see:

About Twig

Twig is a PHP-based compiled templating language. When your web page renders, the Twig engine takes the template and converts it into a 'compiled' PHP template which it stores in a protected directory in sites/default/files/php_storage/... The compilation is done once. Template files are cached for reuse and are recompiled on clearing the Twig cache.

The Drupal Twig initiative shares the same motivation as the Symfony initiative: to adopt a modern, powerful, OOP-based engine that will allow developers to concentrate on Drupal proper.

1. Doc block

PHPTemplate:

  <?php
 
/**
   * @file
   *  File description
   */
 
?>

Twig:

  {#
  /**
   * @file
   *  File description
   */
  #}

2. File and function names

PHPTemplate file: node--article.tpl.php

Expose a filter to site visitors

Your view can expose a filter to your site visitors, allowing them to interact with the data in the view.

Give a custom name to a filter in the Views Edit screen

Sometimes a view can use the same filter in several different ways. To avoid confusion on the Views Edit screen, you can give each use of the filter a different name.

  1. Navigate to the edit screen for a view (for example, admin/structure/views/view/MYVIEWNAME/edit).
  2. In the Filters section, click a filter. The Configure Filter dialog box displays.
  3. Click More.
  4. In the Administrative Title field, enter a name for the filter. This name will only be displayed in the Views Edit screen.

Add a filter to a view

  1. Navigate to the edit screen for a view (for example, admin/structure/views/view/MYVIEWNAME/edit).
  2. In the Filters section, click Add.
  3. In the For field, select one of the following options:
    • All Displays The filter will be added to all of the displays in the current view.
    • This Page (override) The filter will only be added to the current display.

Rewrite the output of a view field

You can configure a field in a view to display information that is different from the actual data in the field. By using tokens, you can enhance the field with dynamic content from the database.

  1. Navigate to the edit screen for a view (for example, admin/structure/views/view/MYVIEWNAME/edit).
  2. In the Fields section, click a field. The Configure Field dialog box displays.
  3. Click Rewrite Results.
  4. Enable any of the following options:
    • Rewrite the output of this field You can replace the field with custom text. When this option is enabled, a list of tokens is displayed which you can use to dynamically add data to the custom text.
    • Output this field as a link You must enter the link path. You can also configure various options for how the link will be displayed.
    • Trim this field to a maximum length Enter the maximum number of characters that will be displayed.
    • Strip HTML tags When this option is enabled, all HTML tags will be stripped. You can also specify certain tags to keep.
    • Remove whitespace If this option is enabled, all whitespace at the beginning and the end of the output will be removed.

Pages

Subscribe with RSS Subscribe to RSS - Drupal 8.x