In working on a bunch of the default views for project* for the d6 upgrade, I found myself needing to access the current value of some view argument while I'm processing a filter. Since filters are handled first, the $view object itself doesn't know its own argument values yet. I wrote a helper function for this that I originally put in project_issue.module, but it seems like something such as this would be valuable for anyone doing more advanced views hacking like this.

I wrote it as a standalone helper function that takes a $view object as an argument, but now it occurs to me that perhaps this makes more sense as a member function on the $view itself.

Thoughts?

Thanks!
-Derek

Comments

dww’s picture

Status: Active » Needs review
StatusFileSize
new1.81 KB

Here's the version as a stand-alone helper. Let me know if you want me to re-roll this as a member function on view objects themselves.

dww’s picture

StatusFileSize
new1.46 KB

Better yet -- now as a member function on the argument class itself.

For example, the callsite in project_issue would look something like this:

  $uid = $form_state['view']->argument['uid_touch']->get_value();
dww’s picture

Title: Add helper function to get the value of an argument from a given view object » Add helper function to get the value of a view argument
StatusFileSize
new1.67 KB

If we already have the value, we can just return it without processing anything.

merlinofchaos’s picture

Status: Needs review » Fixed

Committed! Good work on this!

Status: Fixed » Closed (fixed)
Issue tags: -drupal.org upgrade

Automatically closed -- issue fixed for 2 weeks with no activity.