Closed (fixed)
Project:
Views (for Drupal 7)
Version:
6.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
21 Mar 2006 at 20:31 UTC
Updated:
5 Apr 2006 at 17:30 UTC
Jump to comment: Most recent file
Comments
Comment #1
eaton commentedI need this for a client's site, and the more that can be done with views the better. I'll take a stab at it over the next day or two.
Comment #2
eaton commentedAnnnnd here's the patch. It adds a new db column for each view (block_args), and thus requires a trip to /update.php. A PHP snippet in that field should return an array of args for the view to use -- it will allow the block to display properly, and will also relay those args along in its [more] link if said link is enabled.
I had to poke around in parts of views.module that I'm unfamiliar with, though the changes aren't too drastic. Review would be much appreciated.
Comment #3
eaton commentedThree cheers for feature creep! The re-rolled version of this patch includes a couple tweaks:
if ($type == 'block'), or return an unmolested copy of the $args collection in cases where it doesn't need to do anything special.The 'Argument Handling Code' field is now in its own formgroup, at the bottom of the form. I'd add it to the Arguments section, but I couldn't figure out how to do that given the crafty, funky ways that views_ui builds the fields/filters/sorts/arguments sections of its form. The functionality is working cleanly as far as I can tell.
Comment #4
eaton commentedWhoops. Export wasn't picking up view_args_php. This fixes it.
An example view that demonstrates how it can be done:
Comment #5
moshe weitzman commentedviews_args_php needs some kind of escaping on export. if you look at your paste, you see that it isn't valid php because of the ''
Comment #6
eaton commentedIs there a standard way to do this in views? I double-checked, and the page_header and page_footer fields suffer from the same problem. Putting single-quotes in them yields malformed PHP...
I suppose the fields could be serialized...
Comment #7
merlinofchaos commentedI think check_plain ought to be fine. I think I'd identified that once but must've forgot to fix it, and then thought I had.
Comment #8
eaton commentedNew version of the patch. Uses db_escape_string, and also includes the footer and empty fields that were recently added.
Comment #9
merlinofchaos commentedCommitted. I likely didn't adequately test this, but the code looks pretty solid.
Comment #10
(not verified) commented