I noticed today that many (or perhaps all) of the node family relationship functions that load the related nodes (such as nodefamily_relation_load_by_type, nodefamily_relation_load, etc.) only return nodes where the status is >0. I was wondering what the reason for this is. It seems like it would be better for the user's function (in the template, for example) to check if status > 0 before displaying rather than have the module handle this. Or, you could add in an additional flag to these functions that had a default value of do not return unpublished nodes but with an optional value that would cause all (published and unpublished nodes) to be returned.
I'm asking because I wrote an additional function that automatically creates a nodeprofile type for each new user. That is, the function looks at the relationships established with node family and then creates the nodes I'm using to replace the profile module. However, some of these nodes aren't relevant to certain users, based on the roles granted to the user. Thus, I'm keeping those node types to default to not being published. However, when a user is later granted that role, I want the corresponding nodes to become published. To do that, I'm using the nodefamily_relation_load_by_type function to load all the related nodes, but this doesn't return the unpublished nodes.
I would have no problem changing this myself in the code, but I would rather not have patched modules to maintain myself. If you're not opposed to the addition of another parameter to the functions, I could submit a patch that gives the user the option to get all nodes, not just published nodes. But maybe there's a good reason not to do this that I'm not thinking of.
Thanks
AC
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | nodefamily_min_status_2.txt | 4.47 KB | aclight |
| #4 | nodefamily_min_status_1.txt | 4.5 KB | aclight |
| #2 | nodefamily_min_status.txt | 4.56 KB | aclight |
Comments
Comment #1
fagono, there is no good reason for this. I just thought it's convenient.
So a patch, which creates an optional argument for all the loader functions would be great!
Comment #2
aclight commentedHere's a patch that creates an optional argument with a default value such that the default behavior of the functions is not changed.
Comment #3
fagothanks, looks fine.
But could you please rename the argument to $status? It just looks a bit cleaner.
Thanks!
Comment #4
aclight commentedHere's the patch with $min_status ---> $status
AC
Comment #5
aclight commentedComment #6
fagohm, please roll it against the latest CVS version (4.7 or HEAD, they are the same), otherwise there will be conflicts.
thanks
Comment #7
aclight commentedok, here's a version rolled against HEAD. sorry about that.
Comment #8
fagofinally committed to HEAD and DRUPAL-4-7.
thanks :)
Comment #9
(not verified) commented