New answers tagged views
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().
*/
...
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(...
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)...
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
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.
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 ...
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 = $...
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 ...
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 =...
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 &...
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 }}
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, ...
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....
Top 50 recent answers are included
Related Tags
views × 151737 × 4472
8 × 1969
theming × 1444
taxonomy-terms × 1304
entities × 1271
nodes × 1044
users × 615
blocks × 586
search × 433
javascript × 405
datetime × 401
6 × 397
commerce × 347
ajax × 341
media × 302
panels × 290
hooks × 258
forms × 241
database × 240
9 × 210
i18n-l10n × 199
rules × 195
paging × 183
navigation × 176