New answers tagged

0 votes

Date popup in exposed filter

Drupal 9/10 I Just did a normal exposed filter (for a timestamp / date) field Selected between dates left all defaults blank then added (in a module) /** * Implements hook_form_ID_alter(). */ ...
taggartJ's user avatar
  • 2,087
0 votes

Expose taxonomy term contextual filter in Layout Builder

Pass value in contextual filter programmatically : using hook_views_pre_view(): (can add either .theme/.module file) use Drupal\views\ViewExecutable; function Mythemename/Mymodulename_views_pre_view(...
mini's user avatar
  • 682
1 vote
Accepted

How to style the h2 title of "search results"?

There is not a template file for that <h2> element because it is not rendered using a theme implementation, but from SearchController::view(), which uses the following code. if (count($results)...
apaderno's user avatar
  • 97k
0 votes

Views Row Classes Not Appearing

Copy-pasting a core template into my theme helped resolve this issue: cp ../../core/modules/views/templates/views-view-unformatted.html.twig \ templates/views/views-view-unformatted.html.twig
Victor Pudeyev's user avatar
0 votes

Inform the user what page of the pager it is -- on top of the page as well

In the View add a Header: Global: Text area and fill in the text: [view:current-page] There is a list with more pager variables in the section Available global token replacements.
4uk4's user avatar
  • 98.1k
0 votes

Make a header of a view page to appear only in the view's first page

Install the Filter Twig module: composer require 'drupal/filter_twig:^2.2' drush en filter_twig Visit /admin/config/content/formats/add, enter the name "Views Twig", check "Replaces ...
4uk4's user avatar
  • 98.1k
1 vote
Accepted

Make a header of a view page to appear only in the view's first page

You can use hook_preprocess_views_view__HOOK() hook (in .module/theme file) for display header conditionally: function Mymodulename_preprocess_views_view__machine_name_of_view(&$vars) { $view = $...
mini's user avatar
  • 682
1 vote
Accepted

Sorting by title of a referenced entity instead of ID

Follow below steps to sort inside the view of content type "A", to sort by the Title of content type "B": Take relationship of "Content type B" field for eg: Content ...
mini's user avatar
  • 682
1 vote

Inform the user what page of the pager it is -- on top of the page as well

You can use template_preprocess_views_view() hook to get current page number function Mymodule_preprocess_views_view(&$vars){ $view = $vars['view']; $id = $view->storage->id(); if($id =...
mini's user avatar
  • 682
0 votes

Expose View of Visitors information via JSON:API

Follow these steps to expose visitor data by json API: Create view of "vistior" entity type of rest export Then add required path/url like: jsonapi/views/visitors in path setting Select &...
mini's user avatar
  • 682
0 votes

How can I render a Paragraph field in the views unformatted template?

To render an entity field use the View filter of the module Twig Tweak: {{ row.content['#row']._entity.field_faq_answer|view }}
4uk4's user avatar
  • 98.1k
3 votes

How to format a view to show content but without a teaser?

I advise you to use content rather than fields. In view content, you can choose a view mode. Choose the view mode that suits you (full, teaser) or you can create one for your needs. In this example, ...
Sébastien Gicquel's user avatar
0 votes

How to get views machine name in `block--views-block-html.twig` file?

This would help someone still looking for adding a block template suggestion with View's machine name. You should be able to get the View ID with $variables['elements']['content']['#view_id] if exists....
Harish ST's user avatar
  • 109

Top 50 recent answers are included