Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [views]

The Views module allows creating lists of content with a flexible query builder.

105
votes
3answers
65k views

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 ...
41
votes
11answers
33k 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
9answers
13k 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
4answers
16k 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 ...
33
votes
3answers
20k 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 ...
31
votes
8answers
40k 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?
31
votes
9answers
43k 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
5answers
29k views

Views and node count for taxonomy terms

How can I display the node count values for taxonomy terms in Views? with sorting the result list in descending order of node count.
30
votes
3answers
35k views

Count results in Views using aggregation

Is it possible to count results (e.g. count the nodes of the content type x) in a view, using aggregation (not programmatically)?
27
votes
5answers
21k 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.' ...
26
votes
5answers
21k 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. ...
26
votes
2answers
19k 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 ...
25
votes
3answers
16k 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?
24
votes
5answers
14k 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
4answers
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 ...
24
votes
4answers
11k 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 ...
24
votes
1answer
18k 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 ...
23
votes
4answers
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 ...
22
votes
4answers
21k 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 ...
22
votes
8answers
17k 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
2answers
7k 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 ...
20
votes
5answers
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 ...
19
votes
9answers
43k 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-...
19
votes
6answers
19k 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
6answers
30k 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 ...
19
votes
2answers
14k 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
2answers
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
4answers
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
3answers
9k 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 ...
18
votes
4answers
12k 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
1answer
2k 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
5answers
8k 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 ...
18
votes
6answers
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
3answers
21k 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?
17
votes
3answers
26k 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 ...
17
votes
1answer
25k 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 ...
17
votes
9answers
24k 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
3answers
19k views

Removing main content block on frontpage

I'm new to Drupal 7 and I'm looking to replace the frontpage's default main content block with an equivalent block generated from Views (gaining more control over the block in doing so). I have ...
17
votes
4answers
11k 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, ...
16
votes
6answers
23k 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.
16
votes
3answers
23k 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. ...
16
votes
2answers
8k views

Views exposed filters without “Apply” button

I have created a view with exposed filters of term select list. How can I make the select list to work directly on selecting an item, instead of clicking on the "Apply" button?
16
votes
2answers
13k 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?
16
votes
1answer
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.
15
votes
2answers
14k views

In a view, how can I link a field to the node?

In a fields view, the "title" field has a check box "Link this field to the original piece of content". But this check box isn't available for other fields. How can I achieve this functionality for ...
15
votes
3answers
22k 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 ...
15
votes
9answers
8k 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 ...
15
votes
4answers
10k views

How do I get $view->the actual row number?

How do I get the actual rows number in views-view-field--title.tpl.php in Drupal7 and views3? I know how to get the total by $view = views_get_current_view(); $view->total_rows; But how do I get ...
15
votes
1answer
236 views

What is “Advanced Mode” in Views 3?

In this article the first instruction is On every site, run drush vd to turn the Views settings to the advanced mode. What does this mean? A Google search for "Views advanced mode" yields mostly ...
15
votes
4answers
5k views

How do I filter only the root terms in a vocabulary in a view?

I have have a vocabulary structured as so: Root Alpha Term Alpha 1 Term Alpha 2 Subterm Alpha 1 Root Beta Root Gamma Term Gamma 1 Term Gamma 2 How do I filter the view to show only the root ...