Questions tagged [views]
The Views module allows creating lists of entities with a flexible query builder.
15,177
questions
111
votes
2
answers
68k
views
Contextual filters taxonomy name
I'm adding a contextual filter to a view for a custom content type that has a taxonomy field. The contextual filter allows me to filter by the taxonomy tag id but not by the taxonomy tag name. Meaning ...
46
votes
11
answers
37k
views
Views - Add a wrapper DIV around a Group
In Drupal 7, I have created a View that lists several fields. The fields are grouped by another field (the term ID of the field). The mark up looks like this:
<h3>[Term 1]</h3>
<div ...
36
votes
9
answers
15k
views
How to create a union of two views?
I'm trying to get a union of a user's nodes and comments sorted by "post date".
This post links to sandbox projects for D6 but there is nothing for 7.
This post has an example of using ...
35
votes
4
answers
18k
views
How do I change the ajax loading behaviour in Views?
I have a view with some exposed filters in a block; it uses AJAX and the auto-submit feature so the view is re-loaded as soon as a filter option is changed.
In the short delay between selecting an ...
34
votes
5
answers
33k
views
Node count for taxonomy terms
How can I display the node count values for taxonomy terms with sorting the result list in descending order of node count?
34
votes
3
answers
22k
views
How do I group elements in a view?
I have 8 articles: Article 1 (Gaming), Article 2 (Local News), Article 3 (World News), Article 4 (World News), Article 5 (Gaming), Article 6, Article 7, Article 8.
In a view I would like to group the ...
33
votes
8
answers
51k
views
How do I programmatically show a view block?
I created a view block, whose machine name is "news."
How do I display it using module_invoke() and the machine name of the view?
32
votes
4
answers
32k
views
How do I export/import views?
I know how to do it in Drupal 6/7, but I cannot find where to export/import views in Drupal 8. From which admin page is possible to do it, in Drupal 8?
31
votes
3
answers
42k
views
Count results in Views using aggregation [closed]
Is it possible to count results (e.g. count the nodes of the content type x) in a view, using aggregation (not programmatically)?
30
votes
9
answers
45k
views
How do I remove duplicates when using the random sort?
I have created a view where I am displaying the the node title and a logo (a cck field). In the arguments I have passed the taxonomy term name.
In the result a node is displaying 2 or 3 times; I ...
30
votes
5
answers
22k
views
How do I override a taxonomy/term/% list with a view?
I have a vocabulary attached to a content type. Only one term can be selected to categorize a node made with this content type. The vocabulary is called Vehicles and has terms 'cars, trucks, boats.' ...
29
votes
5
answers
27k
views
How do I add JavaScript specific for a view?
I have a view in my site that has a specific class name. I want to know, inside the template.php file of a theme, how I can know if a view with specific class name is available in the requested page.
...
29
votes
2
answers
21k
views
What is the meaning of the field:delta content type offered in contextual filters in views?
When creating a new contextual filter for a view the list of types includes options such as content:spec (field_spec:delta) where spec is the name of a field I have attached to the content type ...
28
votes
7
answers
57k
views
How to get each field value in views-views-unformatted--view-machine-name.html.twig?
I have an twig file: views-view-unformatted--view-machine-name.html.twig
{#
/**
* @file
* Default theme implementation to display a view of unformatted rows.
*
* Available variables:
* - title: ...
27
votes
8
answers
24k
views
Taxonomy term name as contextual filter for view
In D7 I was able to filter a view according to a taxonomy term name taken from the URL. An example would be this URL
http://www.gbyte.co/tags/drupal-planet/rss.xml
"drupal-planet" would be converted ...
27
votes
1
answer
21k
views
How to create a view type of Entity reference display?
I have an entity which contains a field collection of entity references and can edit the entity references with the Entity selection mode is Simple (with optional filter by bundle), but only Entity ...
26
votes
5
answers
53k
views
How do I programmatically render a view with contextual filters?
How do I programmatically render a view with contextual filters in Drupal 8?
In Drupal 7, I generally use the following code.
$view = views_get_view('test_view'); //test_view is the view machine ...
25
votes
8
answers
32k
views
How do I get the route name of a view page?
In my custom submit handler I want to redirect to a view page Url, let's suppose my view name is team and its path is /admin/team, I find out I should use $from_state->setRedirect('route'); but ...
25
votes
5
answers
17k
views
Expose single filter of combination of two fields in views
I have two user profile fields "Last Name" and "First Name". I also have a user list views. I want to expose "Name" as filter which can search for both Last Name and First Name.
How can I do single ...
24
votes
4
answers
13k
views
Custom query in Views?
At some point I found the need to modify an SQL query generated by Views, in the end I overrode views_pre_execute and changed the query for that specific view.
This feels like an ugly hack to me and ...
23
votes
4
answers
10k
views
Are views cached through the core caching mechanisms or should I be setting the caching directly in each view?
I see there are cache settings in each of my views. Do I need to set these or does the core caching mechanisms in /admin/config/development/performance automatically do some of this and these "extra ...
23
votes
5
answers
30k
views
Get the actual query executed by a view
I need to find out the SQL query that is executed by a certain query. Views module can show the SQL when configuring the view but apparently the query is not the actual query that gets run in all ...
23
votes
4
answers
6k
views
Clean way of building simple taxonomy browser of arbitrary depth
I have spent days trying to determine a clean way to do the following:
Display a list of all top-level terms in a vocabulary with links to their child terms
Upon clicking a link, be taken to a list ...
22
votes
6
answers
38k
views
How to show terms in a Views in its hierarchical structure?
I have create a view to show the terms of the Products vocabulary.
I the view I set:
Format: Html list
Show: field
Fields: Taxonomy term: Name
It works fine but it the hierarchical structure is ...
22
votes
8
answers
18k
views
How do I create a nested tree with terms & nodes with Views 3?
I need to create something similar like this:
Colors (Vocabulary)
Red (term)
Dark (term)
Node 1
Node 2
Light (term)
Node 3
Node 4
Blue (term)
Node 5
Node 6
Green (term)
Node 7
Node 8
(...
21
votes
2
answers
8k
views
Custom views handler without table
This seemed easy at first but I'm losing my hair on this.
I simply want to add a custom view handler that uses no table.
I tried to do as views php proposed, $data['views']['mycustomfield'] in ...
21
votes
6
answers
27k
views
How to filter a View by Date Range (start, end)?
In Drupal 7 with Views an Date module enabled, it was pretty easy to filter a view by Date: The UI just gave you the option to do so.
In Drupal 8, however, the date field and views are part of core, ...
20
votes
3
answers
27k
views
Filtering on node whose user ID is equal to the current user
In Drupal 6 you can have a filter node.uid = current user. How do you do this in Drupal 7?
20
votes
1
answer
30k
views
Contextual filter with a block view
I have a page view("/news") with contextual filter for the topics ("news/design","news/coding"...) which are taxonomy terms and this worked fine. Due to some changes for the mobile theming, I need a ...
20
votes
5
answers
13k
views
How do I use hook_views_query_alter()?
Following what reported in the documentation for hook_views_query_alter(), I created a file named alterform.views.inc and put it into an enabled module called alterform. I added the following code in ...
20
votes
2
answers
17k
views
Using views with a custom table/schema
I need to set up some views that will pull some data from a custom table I created. Some views will need to pull content the regular way and from my custom table (where I may query for a particular ...
19
votes
7
answers
33k
views
Add FILTER CRITERIA in Views Programmatically
I want to add/modify a filter criteria programmatically.
For example, for a view, I added an "Email Address" filter whose value is needed to change dynamically, it is needed to set to the current ...
19
votes
6
answers
27k
views
How do I display/edit the machine name for a View?
How do I display/edit the machine name for a View?
Reason for asking is that I tried cloning a view but the name I gave was rejected because it had already been used but I couldn't see where.
18
votes
9
answers
47k
views
Create template file for views block
There is a lot about theming custom blocks, but what about blocks created by views?
My views block has id: block-views-posts-listing-block,
I try many ways for naming template file, ex: block--block-...
18
votes
3
answers
32k
views
How to pass Views contextual filter via URL?
I want to pass some values to my view via contextual filters in the URL. What GET naImes do I use? There seem to be no clue given, just this "The contextual filter values is provided by the URL".
If ...
18
votes
3
answers
15k
views
Date popup in exposed filter
I'm using Drupal 7 with views 3.
I have used an exposed filter for a date field and I want to provide option to choose date from datepopup for date filter? How can I do this?
18
votes
4
answers
7k
views
How to combine views exposed filter with search?
My client asked me for a single field, that would work 2 ways:
Autocomplete filter based on taxonomy.
If site visitor inputs something that's not in taxonomy, full text search should be performed on ...
18
votes
2
answers
4k
views
Views Block's machine name is being "hashed" (?)
A Drupal newbie, so correct me if my understand is wrong, but normally, when a Block is created by Views, the machine name of the block is appended to the Views' machine name.
i.e. "...
18
votes
4
answers
13k
views
How to use a views contextual filter OR?
After browsing the net and SE for a while it appears to me there is no good solution to combine 2 contextual filters with OR (rather than the default AND).
This post mentions a PHP hack and this post ...
18
votes
1
answer
3k
views
In views, what is the difference between Normal menu entry, Menu tab and Default menu tab
When adding a menu item in views I see three selections that are ambiguius
Normal menu entry
Menu tab
Default menu tab
What is the difference and when would I use each?
18
votes
5
answers
9k
views
How to Filter view by comparing 2 fields. If field-a < field-b
I have a product content type that has 2 price fields.
I want to create a view that shows all products where price-A is less than price-B.
I was hoping I could just add a filter and select price-A ...
17
votes
4
answers
11k
views
Why is the View import option not shown in the views UI?
I'm trying to export/import a view from a dev site to a qa site. Views UI is enabled. However, when I go to structure>views I don't see the "+ import view" option, only:
"+ Add new view" "+ Add new ...
17
votes
1
answer
15k
views
How do I translate a view page title?
Is there a way to translate a view page title in Drupal 8? How can I achieve it, if it is possible?
17
votes
3
answers
29k
views
Views exposed filter to search multiple fields [duplicate]
To my knowledge there hasn't been an option in drupal 7 to create a single exposed filter in a view which searches multiple fields, while in previous versions there existed modules to do just that.
...
17
votes
9
answers
26k
views
How can I create a view of child nodes based on the menu relationship?
Say you have the following pages in a menu tree:
Projects
Project One
Project Two
Project Three
I'm looking for a way to create a view that will be embedded in the Project (parent) page that will ...
17
votes
3
answers
10k
views
Where can I learn about how to create a custom exposed filter for Views 3 and D7?
I am trying to learn how to create a custom exposed filter for a contributed module (select or other). I found this tutorial for Drupal 6 but the code doesn't appear to work out-of-the-box on Drupal ...
17
votes
6
answers
7k
views
View of users flagged by a user, users flagging a user, and nodes from users flagged by a user
I have a user flag that is pretty much like a "follow" or "subscribe" function.
Basically I want to create 3 views for my website's user profile pages:
A list of users flagged by a user (e.g. a ...
17
votes
1
answer
5k
views
How to expose non Drupal tables in Views?
I wonder what is the best way to allow the Views module to access external tables not in Drupal?
I tried the Data module, but it doesn't allow for a datetime datatype.
16
votes
1
answer
13k
views
How can I concatenate two fields in a view?
I have a view set up to use the unformatted list type. I'm pulling in about 10 different fields, but would like to concatenate two of them onto a single line in the display. Is this possible?
Example:...
16
votes
3
answers
25k
views
Load more content with ajax when clicking more link in a view
I have a custom block view. I display the last 5 node titles. If someone clicks the more link I want to load the next 5 titles underneath the current 5 node titles. No page refresh and not pager. Is ...