First, thanks to the developers and maintainers for the excellent LM PayPal module set. I'm marking this as a feature request, but feel free to close as "won't fix" since I'm also going to provide a workaround I've found that delivers the requested functionality---for Drupal 6.10 at least, which is the core version I'm running.
LM Paypal Paid Adverts allows you to set desired node types as requiring payment to be "published", but not "published" in the Drupal node sense---"published" in the sense that a status flag is set to true in one of the LM PayPal Paid Adverts tables, and other code in the module makes the node visible as a result. I need to display a list of paid nodes in a view, but this isn't natively possible since the LM PayPal Paid Adverts tables aren't available to Views, and LM PayPal Paid Adverts doesn't alter the contents of any tables that ARE available to Views. I can't select on node=published either, because an LM PayPal Paid Adverts -type node isn't automatically published when it's paid for.
However, that 'paid' status flag is in the lm_paypal_subscribers table, which also includes node id# (field 'nid'). Since nid is also part of the data set returned by a basic node-type view, I knew if I could somehow access lm_paypal_subscribers from within my view I could filter the records based on paid status. Searching for options to get at that table in a view, I found and installed the Views PHP Filter module, which allows you to filter Views content based on a PHP snippet. I figured I'd create a view with all the node information I wanted in it, then use Views PHP Filter to filter the list of nodes based on a SQL query that pulled the node IDs (nid field) from the lm_paypal_subscribers table.
But try as I might, I couldn't get my PHP snippet right; it just kept returning the first row of lm_paypal_subscribers, even using functions other than db_fetch_array. Thanks to site member nevets for providing this snippet, which works flawlessly:
$nids = array();
$result = db_query('SELECT nid FROM lm_paypal_subscribers');
while ( $row = db_fetch_array($result) ) {
$nids[] = $row['nid'];
}
return $nids;
I pasted this into a Views > Filter > Node PHP Filter field with "handler" type for the PHP Filter field set to "php code", and voila! I have my view that lists data for paid nodes only, regardless of node publication status.
Comments
Comment #1
opdaviesBrilliant! Thanks very much! :)
Comment #2
netourish commentedHi Publetariat ,
Great, Thank you very very much for this post.
I can not express how helpful this post was for me, I was searching for this functinality from last 10 days. And during this period I toggled between "Ubercart" and "Lm_paypal" 4 times each to acheive this, ending up nowhere.
I was just going mad to achieve this.
Then I came across this post.
The way you giuded me (who is very new to this beautiful world) in the post was also very very appreciable and great.
I have few more issues with me regarding the integration of lm_paypal.
Right now, in my site a user can place advertisment in the form of a node. Then he/she will navigate to thier "My Account" page and then subscribe from there to "paypal" by clicking on the "Not published" link. But I want to take them directly to "Paypal" after clicking the "submit/save" button of the node.
Secondly, after successfully paying in paypal it is redirecting to the desired page but the subscribed node is not appearing in the view listing until the page is refreshed manually 3-4 times and also noted that in the "My Account" page the "Not published" link is still there for the node whose payment is done, and once it is clicked then it is appearing as "Published" which is fine. But I want to make this link appear as "published" once the node has been subscribed.
I want the advertisement node whose payment is done to be displayed in the view list (instantaneously) the moment when the control comes back from paypal to the desired returned page. And once the payment is done the link "Not published" should automatically become "Published" for the subscribed node in the "My Account" page.
Any or all guidance/suggestions will be greatly helpful to me for acheiving this.
Thanking You,
Pradeep.
Comment #3
netourish commentedHi, Publetariat ,
I am very very sorry, for the second issue which I have mentioned, It is not the thing which I have mentioned. Actually, I think after payment/subscription of a certain node some time is getting consumed for the completeness of the functionality.
But, I really want to instantaneously show the paid node in the views display.
I request you all out there, Please feel free to reply me if I am unable to make understand you guys (Because my english is not so good.), or redirect me if I am posting my issue in the queue where it shouldn't be.
Thanking you,
Pradeep.
Comment #4
jonathan1055 commentedViews integration now has its own issue #1102400: Views integration