Roy,

The alternative is calling the View directly. As you said you have done now.

As I said, I didn't read the post closely and I don't have time to now. I just wanted to help remove at least one variable for you by alerting you to the fact that testing a View via its "Preview" doesn't work all the time.

Sounds like that isn't your problem and hopefully others will jump in to help.

Shai

On Mon, Feb 15, 2010 at 12:08 PM, Roy R <roy.redirect@gmail.com> wrote:
Hi Shai
Whats the alternative?
Actually I get the same results when I call the view directly.
So the display Page's path is "contrib/my"  ( no arguments), and
typing "http://localhost/contrib/my"  gives the following:

Membership #   Name     Uid
M1019              SGOCI      1

This is the result of the first query, not the result of the second.
The SQL statement in the preview mode is correct as far as I can tell.
So it seems this is a display issue when View arguments are supplied
programatically. The view->execute() statement in my PHP code seems to
be having some undesired effects, because if I replace the php code
with just

return 'M1019';

it works.

Any clues?

Thanks!
Roy



SELECT node.nid AS nid,
  node_data_field_contrib_checkdate.field_contrib_checkdate_value AS
node_data_field_contrib_checkdate_field_contrib_checkdate_value,
  node.type AS node_type,
  node.vid AS node_vid,
  node_data_field_contrib_checkdate.field_contrib_checkno_value AS
node_data_field_contrib_checkdate_field_contrib_checkno_value,
  node_data_field_contrib_checkdate.field_contrib_voucherno_value AS
node_data_field_contrib_checkdate_field_contrib_voucherno_value,
  node_data_field_contrib_checkdate.field_contrib_voucherdate_value
AS node_data_field_contrib_checkdate_field_contrib_voucherdate_value,
  node_data_field_contrib_checkdate.field_contrib_accountno_value AS
node_data_field_contrib_checkdate_field_contrib_accountno_value,
  node_data_field_membernumber.field_membernumber_value AS
node_data_field_membernumber_field_membernumber_value,
  node.title AS node_title,
  node_data_field_contrib_checkdate.field_contrib_amount_value AS
node_data_field_contrib_checkdate_field_contrib_amount_value,
  node_data_field_contrib_checkdate.field_contrib_memo_value AS
node_data_field_contrib_checkdate_field_contrib_memo_value
 FROM node node
 LEFT JOIN content_type_contribution_record
node_data_field_contrib_checkdate ON node.vid =
node_data_field_contrib_checkdate.vid
 INNER JOIN users users ON node.uid = users.uid
 INNER JOIN node node_users ON users.uid = node_users.uid AND
node_users.type = 'profile'
 LEFT JOIN content_field_membernumber node_data_field_membernumber ON
node.vid = node_data_field_membernumber.vid
 WHERE ((node.type in ('contribution_record')) AND
(node_data_field_membernumber.field_membernumber_value = 'M1019'))
   AND ((DATE_FORMAT(node_data_field_contrib_checkdate.field_contrib_checkdate_value,
'%Y') <= '2009' AND
DATE_FORMAT(node_data_field_contrib_checkdate.field_contrib_checkdate_value,
'%Y') >= '2009'))
  ORDER BY node_data_field_contrib_checkdate_field_contrib_checkdate_value DESC


On Mon, Feb 15, 2010 at 11:46 AM, Shai Gluskin <shai@content2zero.com> wrote:
>
> 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@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/ ]
>
>
> --
> [ Drupal support list | http://lists.drupal.org/ ]
--
[ Drupal support list | http://lists.drupal.org/ ]