logo

Extra Block Types (EBT) - New Layout Builder experience❗

Extra Block Types (EBT) - styled, customizable block types: Slideshows, Tabs, Cards, Accordions and many others. Built-in settings for background, DOM Box, javascript plugins. Experience the future of layout building today.

Demo EBT modules Download EBT modules

❗Extra Paragraph Types (EPT) - New Paragraphs experience

Extra Paragraph Types (EPT) - analogical paragraph based set of modules.

Demo EPT modules Download EPT modules

Scroll

How to change the SQL query in views?

22/02/2025, by Anonymous (not verified)

Hello, I need to modify a views query.

I'm using hook_views_query_alter 

function custom_module_views_query_alter(&$view, &$query) {
     if ( $view->name == 'uc_catalog_terms' ) {
	   $query->where[0]['conditions'][0]['field']="SUBSTRING('taxonomy_term_data.name, 1, 1)";
  }
}
However, the query removes all characters, resulting in views making the following query:
WHERE (( (SUBSTRINGtaxonomy_term_data.name11 = 'a') ))
Why are the characters being removed, and how can I address this?
 I found on a foreign forum that the error was in version 7x.3.dev,
I am using version 7.x-3.7