Quantcast
Channel: Question and Answer » hook-views-query-alter
Browsing index pages (26 articles)
↧

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


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


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

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

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


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

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

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


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


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

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

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

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


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

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


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

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


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

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

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
Browsing index pages (26 articles)


Latest Images