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

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

How to add a correlated subquery expression in hook_views_query_alter?

In hook_views_query_alter, how to add a condition which is a correlated subquery in which the value of the condition is an expression? Given a view the produces this query: SELECT node.nid, node.title,...

View Article


How to perform COUNT aggregate function using hook_views_query_alter()?

I have fields post_date and nid in my view and I need to get count of nid upon group by post_date. Using hook_views_query_alter(), function custom_views_query_alter(&$view, &$query) { if...

View Article

Alter views limit using hook_views_query_alter

I’ve used display specified number of items for set limit in views. I want to change limit and also display all items using hook_views_query_alter(). I’ve tried this: function...

View Article

view's query “was not run” while getting results

I’m working with drupal 7 and views module (7.x-3.11 version) and I’m getting a strange problem. In the Views admin, when I run the query, I get a message no query was run while I actually get expected...

View Article


db_select throws PDOException

Trying to do a simple query from a table called ‘raffles’ under the drupal database. It is not a complex query, Just trying to get all sets from drupal.raffles $query = db_select('raffles');...

View Article


Limit row items to 1 as per the GROUP BY result in Views 3.x

I’m trying to limit row items to 1 as per the GROUP BY result in Views 3.x, below is the view which I’ve created but I’m missing the key part from that, below is the exported code of my view. $view =...

View Article
Browsing latest articles
Browse All 26 View Live