Hi there,
Several times, I ran into the same "problem": I needed to make a complex SQL query to be used in a View, but unfortunately there doesn't seem to be a nice solution yet.
I also discussed this with two of my colleagues and they could confirm that.
After some research, I found these modules:
- http://drupal.org/project/qviews
- http://drupal.org/project/views_modify_query
But...... qviews hasn't been active for over 6 months and has serious security issues.
And...... views_modify_query hasn't been active for over 1 year, besides, it looks like it does not exactly what I want.
It looks like this workaround is exactly what I (and apparently other developers) need:
- http://drupal.org/node/409808
So, today I made a lightweight custom module (Views SQL override) that does the same as described in the workaround, but with a nice and easy GUI.
What is the best for me to do? I understand that fixing qviews might be the best option, because it's way more advanced than "Views SQL override 0.1", but I am afraid it would take me too much time to completely fix it.
So right now there are no good options for developers and "Views SQL override" just..... does the job.
I look forward to receiving your opinion....
Thanks in advance!
Greetings,
medieval111
P.S. I couldn't attach non-doc files, so I uploaded the Views SQL override module here: http://fotogalerij.org/Drupal/views_sqloverride-6.x-0.1.zip
Comments
I understand exactly where
I understand exactly where the background for modules like these come from, but given that Views is supposed to be a query builder, it feels a bit wrong to be creating manual SQL like this. I'm curious, have you talked about these modules with any of the Views maintainers? I'm curious as to what their thoughts are.
+1
I was just wishing for something like this yesterday! I love Views, and I use it on all my sites, but often I have needed to do things that would be simple with a query but are impossible in Views without re-writing handles and views data arrays, a task which is far more complicated and time-consuming -- and far less documented -- than MySQL. I would just do the query and put stuff together myself, but I didn't want to give away the integration and optimizations that so many people have spent so much time on with Views. I'll definitely take a look at your module!
Here is an alternative variant of Views custom query...
You can find it here: http://drupal.org/node/409808#comment-2560626
Sounds interesting
I'd like to look at the code, but the download link seems to be dead... Any chance it could be re-uploaded somewhere?
I like how views works overall, but sometimes I'd like to just get in there and write the query myself, then pass the result off to a designer so they can work their theme override magic on it.
@medieval111 Hi is any chance
@medieval111
Hi is any chance get your module because the link above is dead.
Thanks M.
Hi marinex, I am afraid I
Hi marinex, I am afraid I don't have the code anymore :( But it was for Drupal 6 anyway.
Maybe you could try one of these things:
1. Create a view in MySQL and import the data in your Drupal view with the table wizard module.
2. Create a custom module with a hook that overwrites the view's SQL code. In Drupal 6, it was something like:
<?phpfunction hook_views_pre_execute(&$view) {
if($view->name=="<VIEW NAME>") {
$view->build_info['query']="<SQL QUERY, I suggest you first build the view, copy the query and then edit it>";
}
}
?>
Would like to hear from you how you fixed it!
Views Raw SQL
FYI, I made http://drupal.org/project/views_raw_sql to solve a similar problem in D7.
Thanks I used the solution
Thanks I used the solution with hook_views_pre_execute... because I am working in D6 web project...