Hi danielb, me again! Getting ready to launch a subscription-based site using this module (with a how-to write-up to follow once it launches), and I discovered a bug in testing the product purchases.
I've set it up using Views as you suggested in #1204380: Grant access to a Book (collection of nodes)? and it works beautifully -- however, access is only being granted to the first 10 nodes returned by the view. The view is set to return all nodes, and when putting the argument in manually (in View preview) it returns all results.
Since 10 is the default display count used by views, is it possible that NAP isn't detecting/overriding this?
Here are some of the things I've tried:
- upgrading to latest dev
- creating a new display on the view (then remembered that NAP only uses the default display)
- creating a new view
- deleting the item from nap_products and emptying nap_purchases and nap_transactions
Comments
Comment #1
danielb commentedYeah you have to remove the pager/limit in the view...
You can do that easily by creating another 'display' in the view which is specifically tailored for use with this module.(edit: oh bugger, no support for displays - you'd have to clone the view)I'll see if there's a way to override it at execution time, but no guarantees.
Comment #2
danielb commentedI've added
$view->display_handler->set_option('use_pager', 0);tonap_get_nids_from_view()and committed it.I used this in another module to override the views pager, so I think the same thing might work here.
This will appear in the next dev release (check the dates).
Comment #3
akalata commentedThanks danielb. I've had the limit removed through the Views UI for awhile without any luck (and previewing the view works fine, just not when its called problematically).
I've tried the latest dev (and confirmed that the code you mentioned above is in the release), without any change in the behavior. I can play around with some other views stuff now that I know where it should be -- I'm meeting with the client now and I wanted to surprise them with a fix if I could. :)
-A
Comment #4
danielb commentedI don't have ecommerce or ubercart installed on my test site, and those are a major pain to install and configure.
Have a look at this page and see if you can swap out that 'use_pager' code I added with something from this issue:
#711114: Disable paging when executing view programmatically?
Possible options:
or
That issue also seems to suggest there is a difference between Views 2 and Views 3 regarding this.
Comment #5
akalata commentedThanks for the pointers, but it looks like the original code was right all along!
As I started trying different things and figuring out how the nap module worked to assign the nodes, I realized it was based on the nodeapi 'update' $op. While I had been resaving the node, the value for the NAP product was never changing, so the node_access list was never updated. Once I changed the argument value, changed it back, and rebuilt permissions, all the nodes appeared as they should.
I'll leave this marked as 'needs work' so you can take the line you added out of -dev. I really appreciate all your support!
-A
Comment #6
danielb commentedWait what do you mean by original? The first change I made, or how it was before this issue?
Is your view still configured to 10 per page? That would be the ideal test case, as it's the default.
Comment #7
akalata commentedHow it was before this issue. My view was never configured to 10 per page, but was only showing 10 results. I believe this was because only 10 nodes were in the view result when the product was saved with the view name and argument -- as more nodes were created, they were not being added to the product, since the product wasn't being re-saved (if I'm reading nap_nodeapi() and nap_create_update_queue() correctly).
Re-saving the product node by removing the argument, saving, and re-adding the argument, and rebuilding node permissions successfully generated access to all intended nodes, using the module code before
$view->display_handler->set_option('use_pager', 0);was added.Comment #8
danielb commentedOK thanks mate. I don't think the new code should really hurt it though? Might leave it unless I find out it's doing something bad.
Comment #9
akalata commentedSorry for all the confusion! I was getting errors with the added code, but they were just php notices :D
Comment #10
danielb commentedAlright lets leave this open, when I get around to setting up a test site and solving the other issues here I will do some tests on this.
Comment #11
danielb commentedComment #12
danielb commentedI've removed the added code.