Questions tagged as ['views']

The Views module allows creating lists of entities with a flexible query builder.
Score: -1
View with multiple blocks, how to specify which is shown?
ph flag

I have a view that is placed as a block below my main content. Within that view I have block "displays". each having a different contextual filter for their id from url.

The problem is when the view is displayed, it only shows one of the Displays, how do i specify which is shown ?

enter image description here

Score: 0
I get a block that doesn't change on other pages
us flag

I have an issue with the contextual filters when I use Content: ID. On the site I get a repetitive, when there are many more recipes.

The block remains the same, with two recipes, which is fine, but they don't change on another page. It's always the same.

I hope this makes sense.



Contextual Filter


Main Issue

Score: 0
Ivan Ginovski avatar
Display Node Local Tasks Menu on View
jp flag

I have a view that shows registrations for an Event (Content Type). This tab is shown in the /node/{node}/edit:


This registrations tab refers to the view, which I have inserted in the routing.yml:

  path: '/node/{node}/registrations'
    _entity_view: 'registrations.page_1'
    _custom_access: '\Drupal\events\Access\EventsRegistrationsAccess::checkAcc ...
Score: 0
user3108268 avatar
Set a Data Value from Text field to Term Reference field
us flag

Node has two fields:

  1. Text field
  2. Term reference field (autocomplete?)

The Text field is old and already has 500 nodes with 500 unique values.

The Term reference field is new and needs to contain same data.

So e.g. one node has Text field value of 123, the Term reference field also needs somehow to have it set to 123?

enter image description here

In Rules Set a value data only lets you copy content from term reference field ...

Score: 0
Pass parameters from block to a JSON endpoint using taxonomy term from URL
pk flag

I've been searching for a solution to being able to pass a taxonomy term on a views block that is on a given page using the term name that is in the URL. I agree with my team that it would be a best practice to have one block that can be placed on multiple nodes to pull relevant data from a JSON endpoint, on another server, rather than have a proliferation of one block for term.

Example endpoint  ...

Score: 2
Baud avatar
How to create a view filter which display nodes if "field1" - "field2" < $amount
sa flag

I have a content type with 2 fields: field1 and field2

I would like to create a view filter which display node based on a calculation on those two fields.

The filter should display only nodes if field1 - field2 is lower then a given amount.

Here is my try: At the end of the code, I don't know how to create the query

 class Myfilter extends FilterPluginBase implements ContainerFactoryPluginInterface ...
Score: 0
How do I change a display plugin class
vn flag

I'm attempting to modify the definition of a view display plugin to use my own custom class. I used hook_views_plugins_display_alter(), but it doesn't seem it's invoked at all. I've searched in core code where the hook is invoked, but I didn't find it.

Does anyone know an example of using this hook, or another way to override the class for a view display plugin?

Score: 0
khadidja avatar
Views Infinite Scroll class wrapper goes away when filtering using facets, changing my CSS styling
cn flag

I have a page with custom css that uses display:grid for content output from my view. The limit I have for what my view outputs is 30.

Since the views infinite scroll contains a wrapper around my content, my css grid styling is all there, however when I use my facet to filter anything with an output less than 30, the wrapper vanishes as does all the styling. The wrapper then becomes a different c ...

Score: 0
hotwebmatter avatar
Views Jump Menu containing only sibling taxonomy terms
nr flag

I'm using Views Jump Menu with Drupal 9.

Nodes are tagged with a software_version hierarchical taxonomy, following this pattern:

├── foo
│   ├── 0.1.0
│   └── 0.2.0
├── bar
│   ├── 0.3.0
│   ├── 0.3.1
│   └── 0.4.0
└── baz
    ├── 0.1.0
    ├── 0.2.0
    └── 0.3.0

The plan is for nodes of a custom Content Type to  ...

Score: 0
Andrew Perriman avatar
How do I set up a views block that filters contextually on a field included in a paragraph?
in flag

I have two content types (ContentA, ContentB) which both use the same paragraph (MyParagraph) as field type “Entity reference revisions.”

MyParagraph consists of two “List (text)” fields: ParagraphFieldA, ParagraphFieldB.

The values for ParagraphFieldA and ParagraphFieldB come in both cases from allowed values lists which have a key and label.

ContentA is limited to one MyParagraph reference bu ...

Score: 0
How to save contextual filters (taxonomy) used with one content type to another?
mg flag

I'm quite new to Drupal and I'm building a site where the user will be able to filter content using taxonomy (for example location, price range free/cheap/expensive,etc.). I want this filter to be kept between pages, from a global view to a specific content and even for different types of content.

Example : User selects a place, a price range. The view is updated with proposed activities. User op ...

Score: 0
Display Block to retrieve information from Order Item's Product Variant and display rating & review inside product page
cn flag

I am working on an e-commerce website development. I have the conventional Products -> Product Variants which goes through Order and payment gateway workflow. However, there is something different in this conventional scenario.

I have setup Product -> Product Variation to categorise the different type of fabrics which fall under a same style.

We have different kinds of fabric which we source f ...

Score: 2
Can you rename replacement pattern tokens in views?
ru flag

If you insert one or more custom text field (e.g. to include some Twig logic), latter fields will see such blocks as {{ nothing }}, {{ nothing_1 }} etc. in the replacement patterns.

Can these be renamed? The label and the admin description make no difference.

Score: 0
Using Twig in global custom text to check for a specific content type
in flag

I am filtering for two content types to display in a view: Artwork Page and Cover Page. I want to change the HTML markup for Cover Page.

I have researched and tried many field names for Content Type, but with none of them I get what I am trying to achieve. In this instance, the replacement pattern for Content Type is {{ type }}; using it doesn't work. I've tried both the machine name (cover_page) an ...

Score: 2
hotwebmatter avatar
Pathauto alias full path for hierarchical taxonomy terms
nr flag

My client has content tagged by a hierarchical taxonomy of arbitrary depth.

Currently the maximum depth is three, but that could change:

└── ChildTerm
    └── GrandchildTerm

Each Term has a unique TID (of course), but many Terms (especially descendants) share identical strings for Name.

However, the full Taxonomy tree path to each term is guaranteed to be unique (two adjacen ...

Score: -1
Engin Yilmaz avatar
Sum the grouped results in the template
ng flag

I have an aggregated view result grouped by taxonomy terms and shown like the following.


I want the result to be added and shown like the following.


I tried to calculate the result in views-view-fields--reports.html.twig file with the following code.

{% set total = 0 %}
{% for field in fields - ...
Score: 1
KTM avatar
Modify sorting criteria using views_query_alter
fi flag

I have a view for the content type events with fields event_name, description, summary, event_start_date, etc. What my requirement is:

  1. Sort the events in ascending order of event_date equal or greater than the current date (upcoming events)
  2. Sort the events in descending order of event_date less than the current date (past events)

NOTE: the upcoming data should come first and then the past data.

Score: 0
Frank0051 avatar
Rewriting Start and End Dates in Views where Date is stored in single field
do flag

using Drupal 7, I have the Profile2 module installed. Within that, I have a field called "Employment Dates" and a user can enter a start and end date on this field. They can also leave the end date field blank.

I then have a view that has this field. It works well when there is a start and end date (for instance it will show Aug 2012 to Aug 2016 if that's the values entered) but when there is onl ...

Score: 0
Twig template for just one page in a view
br flag

I have a Drupal view (Product Section) where I have a master view. This is the view I'm currently using for Computers, Cell Phone, and other pages I am still creating.


I also have a Product Shop page, which is almost like the parent page. For this page, the path is /products, for Computers is /products/computers, and so forth.

In my theme folder, inside of the templates folder, I created a page--produc ...

Score: 0
Unable to check if variable is empty in views twig
in flag

I am trying to overwrite views-view-unformatted.html.twig file and want to check if title variable is empty or not, but whatever I do, it always acts just like it is not empty.

I know title variable is an object, I tried dpm() it but no modifiers work in checking if it is empty.

My code:

 * @file
 * Default theme implementation to display a view of unformatted rows.
 * Available variables:
Score: 0
Arto Rovie avatar
How to sum views field value
pe flag

A have Drupal 8 and a custom module, which adds a custom field to a view. I want to sum two fields in each views row.

In my module I sum two field values:

  public function render(ResultRow $values) {

  $value = $this->view->field['field_one']->original_value;
  $value_two = $this->view->field['field_two']->original_value;
  $sum = $value + $value_two;
  return $sum;


but I get a num ...

Score: 0
Nested conditions groups in views filter plugin
ni flag

I need to nest some "where Groups" on a QueryPluginBase query, but I can only nest first depth group to the main "where" using setWhereGroup. I need to add groups into another groups but there isn't a function to do it because setWhereGroup let you add a new OR/AND group but I can't set the parent group ID I'd like to nest. For example, I'd need:

((Condition1 OR Condition2) AND ( (Condition3 OR Condici ...
Score: 2
Wingman avatar
Join with Like in Views Plugin
kr flag

Attempting to do a join with a LIKE operand in a Views filter plugin. The query looks similar to below; however, when it executes, the LIKE operand is not taken into account and the join is done with '='. Is there a way to do this type of join?

$configuration = [
     'type' => 'INNER',
     'table' => 'path_alias',
     'field' => 'CONCAT(\'%\', path_alias.path)',
     'left_table' =&gt ...
Score: -2
Jiah avatar
Jquery to move field above the table - changes during page refresh
in flag

I have the below jquery code to move a multiselect field and a button above the table.

  $('#views-form-resources-block-1 .form-item-ka-types').insertBefore($('#views-form-myblock-block-1 table'));
  $('#views-form-resources-block-1 #edit-actions--2').insertAfter($('#views-form-myblock-block-1 .form-item-ka-types'));

In this code I am moving the ka-types field a ...

Score: 1
khadidja avatar
Display multiple values in separate rows with view that uses Search API
cn flag

Yesterday I asked this question, but after realizing the issue was specific to my view relying on an indexed field using the Search API module I wanted to make another post getting more specific help.

So I have a content type, "Person," that uses an entity reference to assign each person a program. I'm trying to make a "People" page for my site that groups the people by said program that they are in ( ...

Score: 2
khadidja avatar
Changing how to group by
cn flag

So I have a content type, "Person," that uses an entity reference to assign each Person a Program. I'm trying to make a "People" page for my site that groups the people by said program that they are in (ex. Human Resources, Engineering, Design, etc. etc.)

Screenshot of Grouping By in Drupal View

I've done this by grouping by Program in my View. This then spits out a header for each program in the list. That works just fine! However, some folk ...

Score: 2
edMan avatar
Set a dynamic filter value
pk flag

I want to construct a view with following constraints:

  • Show entries from the content-type XY AND it is authored by the currently logged in user


  • Show entries from the content-type XY AND the first field/column corresponds to the currently logged in user


  • Show entries from the content-type XY AND the second field/column corresponds to the currently logged in user

I do know about contextual filt ...

Score: 0
liquidcms avatar
Is it possible to define the destination that Views adds to links?
us flag

Views has a field to create a dropdown menu and this has the option of having the destination added to those links. This works great. Unfortunately, if the View is used through an AJAX call the destination ends up looking like it should return to the AJAX call rather than the page which launched the ajax call. This core Drupal bug: is reporting this is ...

Score: 1
Add additional taxonomy term fields to an exposed filter form
in flag

Brief: How to add a custom field from a taxonomy term into a View's exposed filter form?

Specific: I have an image field added to taxonomy terms that I want to add to the exposed filter form along with the radio button and the TID's name (default is only radio + name), themed with Twig template.

More words:
I'd like to modify an exposed Views filter form to include the rendered image field fro ...

Score: -1
ldnddev avatar
Taxonomy term relationships
cn flag

I have 3 taxonomy terms that I would like to expose as filters but I would like to use JavaScript to disable filters as you make selections in the other related exposed filters. For example:

Styles Makes Models
Cars BMW 750i
Trucks Ford F-150

If you select "Cars" then the "Makes - Ford" and "Models - F-150" would be disabled. I currently have each item assigned a proper CSS class for ho ...