Quantcast
Channel: Question and Answer » hook-views-query-alter
Browsing all 26 articles
Browse latest View live

how do I add a table and where clause to query object using...

I currently have a unique situation whereby I need a to use a different term reference field in a view’s contextual filters based on a node’s content type value. I don’t want to have to manually add a...

View Article


Add a JOIN with a subquery into a views query

Here’s my SQL, which I am trying to include in hook_views_query_alter() to modify the uc_catalog view (from Ubercart 3): JOIN ( SELECT uc_products.nid, MIN(uc_products.sell_price) AS min_price FROM...

View Article


how to use hook_views_query_alter() to modify where condition?

I’m trying to modify the where condition of a views query. till now I was successful with altering “order by”, but I have no idea how to alter the where condition. I want to check the search_term and...

View Article

How to alter view query to display only 5 top records

I couldn’t find a similar problem on the forum so I am asking. I created a view with exposed filters but when I visit the view page I am going display 5 top recent record for specific content type....

View Article

modify query sent by views in chart API module

I am using Google Charts API module to generate a pie chart of a content type with the fields Blood-group and count representing the sectors . For this I need to completely alter the query ( select...

View Article


hook_views_query_alter() order by taxonomy term name

I am using Drupal 7 with dataTables and everything works great except that the sort by taxonomy term is not working properly. The data is sorted by tid instead of term name so I was wondering if there...

View Article

How JOIN a subselect to main select 'node' fields

For posting purposes, I have removed all sorting, entity relationships, extra fields etc etc from Main View. Main view returns 1200 rows Subselect returns 176 rows After aggregation the main view...

View Article

Append more nodes to views result

What’s the best Views Hook and the best method to append more nodes to an already queried views result? I wanted to build a node type (Type A) with node references to another type (Type B), and also a...

View Article


Image may be NSFW.
Clik here to view.

How to use custom tables in Views

I have multisite DRUPAL6.26 website using VIEWS 3.0 module in it. Both sites are install in single DB. The first/parent site has no prefix for its tables.EX: node,block,role etc.. The second/childsite...

View Article


Views hook query alter, change the DatabaseCondition Object

I am trying to alter views filters with hook_views_query_alter like function custom_views_query_alter(&$view, &$query) { foreach($query->where[1]['conditions'] as $idx => $condition) {...

View Article

Add group by to views join via hook_view_query_alter

I am trying to add a GROUP BY to a JOIN via hook_views_query_alter and I can’t seem to get it right. This is the psuedo-ish query that I’m going for (: SELECT * FROM node LEFT JOIN ( SELECT * from...

View Article

View query alter joins view_joins construct() with condition

We are trying to alter view query, by joining table with extra condition related to other table in the query to avoid duplicate, $join2 = new views_join; $join2->construct('mls_state',...

View Article

How to modify drupal views query

So Drupal views is creating a query and I need to change the where clause conditions and move it to the on clause. This seems to give me the results that I am looking for. I can not figure out how to...

View Article


Views: how to make an OR condition between filters and contextual filters

I have been able to separate Views filters into groups and apply an OR condition, following this article: http://www.webomelette.com/drupal-views-filters-and-or-logic I also understand how to use the...

View Article

Image may be NSFW.
Clik here to view.

Change view query

I’ve a view and I would like to change it’s query (slightly). Below is an example of what I have. SELECT * FROM {node} node ORDER BY my_field ASC I want to inject ‘COLLATE utf8_danish_ci‘ into query....

View Article


How to alter drupal views filter by start date query

I need to display only future events with start and end date greater than or equal to today’s date. I am using drupal with oracle. When i am trying in views UI, its giving me an SQL error.

View Article

How to hook_views_query_alter arbitrary field and use it in view GUI

For the life of me I can’t figure this out. I have vast and complicated drupal 7 site and among other things I’m using profile2 module. Not sure why, but a few years back I’ve added field directly to...

View Article


Clean url for custom query parameters

I have a custom filter form in my site and the form submitted by the filters adds 2 Get variables to the url. However, the variables appear in the form of:...

View Article

Is there a way to search for instances of hook_views_query_alter() in my...

I am running a D7 site that someone else built and I’m having trouble seeing how an SQL command in a particular view has been altered. In particular, the attributes in the SELECT statement appear to...

View Article

Ajax pager failure in view after modifying view on hook_views_query_alter

The requirement is for different pages on the website to show different Twitter feeds according to the current page. There is a context (triggered according to the path) that inserts a view block into...

View Article
Browsing all 26 articles
Browse latest View live