[support] View with default argument does not display when using PHP

Shai Gluskin shai at content2zero.com
Mon Feb 15 19:46:13 UTC 2010


Hi Roy,

Please note that I did not read your post thoroughly or truly consider your
question.

I'm just writing to let you know that Views "Preview" functionality is a bit
funky, it doesn't work reliably in all situations. I don't rely on Views
Preview for anything. Do you really need it?

Shai

On Mon, Feb 15, 2010 at 7:14 PM, Roy R <roy.redirect at gmail.com> wrote:

> Hello Drupal gurus,
> Newbie drupal user trying to set up a website for a non-profit org.
>
> I am using Content Profile to capture a Member Account Number field in
> a CCK text field.
> I have a Content Type for Contributions which basically lists each
> contribution received, it has CCK fields for amount, check#, date, and
> Member Account Number (shared field with Content Profile)
>
> I want to add a menu option called "My Contributions" that will
> display a table listing the contributions for the current user for a
> given year (exposed filter on year) i.e. I need to get the Member
> Number field, and use that to filter the Contributions nodes.
>
> Reading various posts online I understood the best way to do this was
> to use Views to retrieve the Member Account Number from Content
> Profile and use that to create a default argument for another
> Contributions table View. So I have a view called
> "user_profile_select" that basically retrieves the user profile for
> the current user. (1 record only), and a second view that takes two
> parameters, a date, and a Member Number. The following code is added
> to the default argument section of the Contributions table view.
>
> $view = views_get_view('user_profile_select');
> $view->execute();
> if ( count($view->result) ) {
>   $ret =
>
>  $view->result[0]->node_users_node_data_field_membernumber_field_membernumber_value;
>   return $ret;
> }
> else {
>   return false;
> }
>
> This kind of works, I can see that the correct Member number is being
> retrieved from the first view, and the second view's SQLs WHERE clause
> shows the correct argument. But the View does not display any records
> in Preview mode. If I pass in the same parameters manually, via the
> Preview text box, it works.
>
> What could be going wrong?? Thanks in advance for your help.
>
> Also please let me know if there are any easier alternatives to doing
> this? I tried playing with Panels and Contexts. My thought was I
> should be able to put the first view (user_profile_select) in a Panel,
> and add the second view to the same panel and have the second view
> pull its arguments from the first view's context. But this apparently
> does not work, I cannot see any CCK fields in the context.  I thought
> this kind of simple header/detail displays might be supported out of
> the box.
>
> Regards
> Roy
> --
> [ Drupal support list | http://lists.drupal.org/ ]
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/support/attachments/20100215/92bad241/attachment.html 


More information about the support mailing list