I have an interesting and possibly edge case I need to deal with to utilize more views on one of my sites.

http://www.folkjam.org is what I'll describe as a location aware site. People list events to it and every event is required to have a valid latitude/longitude to make it onto the site. We ask the user to tell us where they are. We then use db_rewrite_sql to constrain the displays to only show content within a configurable radius of the user's location. That's the location aware bit.

Some of our displays need to show all of the content and pass over this location aware processing logic. Our hook_db_rewrite_sql() can be disabled per-query by passing array('location_filter_suppress' => true) into the db_rewrite_sql() call. With views, I see no path to pass arguments through to db_rewrite_sql().

I recognize that this is not a common need.

It looks like this functionality was partially contemplated at one point. Witness

function views_build_view(.....
...
  $query = db_rewrite_sql($info['query'], 'node');
  if ($use_pager) {
    $cquery = db_rewrite_sql($info['countquery'], 'node', 'nid', $info['rewrite_args']);
    $result = pager_query($query, $limit, $use_pager - 1, $cquery, $info['args']);
...
}

$info['rewrite_args'] gave me hope that a patch would be as easy as making the count query for the pager consistent with the data query above it by passing $info['rewrite_args'] into it.

I don't see any code anywhere in the views code base that makes reference to 'rewrite_args'. As near as I can tell it is not set anywhere, nor can I influence the value through the views I define in hook_views_default_views(). So much for a simple solution.

I'll gladly create and test a patch for this feature against the 1.5 version of the views module for Drupal 4.7. I need some guidance on what to alter. I've not used views much because of this 'limitation' in the context of folkjam.org and my familiarity with the module's internals is low. Thanks for bearing with me as I learn.

Scott

Comments

scott.mclewin’s picture

Version: 4.7.x-1.5 » 5.x-1.6

I realize this issue has sat for a while. I'm still rolling my workarounds forward and would love to have support for passing parameters along to db_rewrite_sql() from views that I define programatically.

My offer is now to create and test a patch against the 1.6 version of the Drupal 5 views module. No, I'm not on D6 just a week after it went live. :)

Scott

sun’s picture

Status: Active » Closed (won't fix)

Sorry, Views 1.x is major feature-freezed, and if I'm not mistaken, Views 2.x for 6.x already takes arguments for db_rewrite_sql() into account.