Closed (fixed)
Project:
Views (for Drupal 7)
Version:
6.x-2.6
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
11 Jun 2009 at 18:31 UTC
Updated:
9 Jul 2009 at 09:30 UTC
I want to create a few views in Views and then access them in a separate module. Is there a way I can get at the SQL that a view creates? Also, is there any way I can get a list of views available on the site?
I've found http://drupal.org/node/99612 which lists some functions which I think might be useful, but I'm not entirely sure...
Comments
Comment #1
dawehneryou can get it using $view->build_info['query']
Comment #2
liquixis commentedviews_get_all_views() - http://drupalcontrib.org/api/function/views_get_all_views
views_embed_view() - http://drupalcontrib.org/api/function/views_embed_view
http://drupal.org/node/99612 is for "Views 1" not "Views 2"
Comment #3
jim0203 commentedThanks @dereine and @overall, that's great! This isn't really documented anywhere (as far as I can see) so as soon as I've worked out precisely how to get it to do what I want to do I'll write a noob's tutorial.
Comment #4
frdesign commentedI'm no php pro but with this little tutorial as a starting point I've been able to do cool things with views.
http://www.broadlatitude.com/blogs/matt/content/drupal-tip-never-query-c...
Comment #5
dawehner@frdesign
i just see that you are missing $view->pre_execute() :)
Comment #6
frdesign commentedAh, no wonder I was had a couple of issues controlling how many results to show (found a hack that worked). Thanks for the heads up dereine! I'll go back and update my code. :-)
Comment #7
dawehnerso this is fixed
Comment #8
jim0203 commentedI've written a tutorial on getting started with this sort of stuff at http://state68.com/node/2. It's designed to be useful for total Views noobs like me - hope it helps some people. Thanks again to all who helped me out.
Comment #9
Roi Danton commentedFor a more detailed description than the tutorial posted in #8 provides see Get the result a view creates.