Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
It will be very useful if this module will be able to pass field values as arguments.
Possible use cases:
1. Pass taxonomy terms of current node to display 10 nodes with similar terms.
2. Pass string (select widget) to select content type of the nodes we need to display.
3. Pass flag field to display only flagged nodes.
4. etc.
Comment | File | Size | Author |
---|---|---|---|
#25 | views_attach_cck.patch | 11.3 KB | eabrand |
#24 | views_attach_cck.patch | 12.8 KB | eabrand |
#19 | 399648-cck-arg.patch | 9.76 KB | agentrickard |
#18 | 399648-cck-arg.patch | 9.56 KB | agentrickard |
#11 | 399648-cck-arg.patch | 9.52 KB | agentrickard |
Comments
Comment #1
Sam Dark CreditAttribution: Sam Dark commentedI'm going to implement it this week.
Comment #2
Sam Dark CreditAttribution: Sam Dark commentedMade a patch (against DRUPAL-6--1) that integrates Views attach with powerful Token making it possible to pass virtually any arguments to views.
Comment #3
agentrickardThis is good stuff.
Attached is a revised version of the patch that handles the argument replacement in
pre_execute()
in order to allow previews to work properly.It also cleans up some code style issues.
Comment #4
Sam Dark CreditAttribution: Sam Dark commentedThank you for this patch.
I've merged it with my latest code and tested on development server.
Comment #5
agentrickard@Sam Dark
Are you seeing cases where only 10 results are returned even if "unlimited" values are set? We are having this issue and are trying to track down where it comes from.
Comment #6
agentrickard@Sam Dark -- disregard that last bit; we need to call the parent method during pre_execute.
Your re-roll re-introduced some code that we deliberately took out when we moved the logic from hook_nodeapi to pre_execute().
Comment #7
agentrickardUrk! Last patch was against the wrong svn revision.
Comment #8
Sam Dark CreditAttribution: Sam Dark commentedIt seems Node content can't override default view value right now. I think additional argument should be passed when building a view with arguments somewhere near $result = $view->execute_display($info['display'], $args);
Comment #9
Sam Dark CreditAttribution: Sam Dark commentedSorry about that. Will test latest patch with my installation.
Comment #10
agentrickardI do not understand the report in #8. For example?
Currently, any argument defined by the View will have token transformation performed, if a token is set.
Comment #11
agentrickardThe previous patch was overwriting non-token arguments.
Comment #12
Sam Dark CreditAttribution: Sam Dark commentedLatest patch does not work for me.
Test case.
View displays top 10 nodes. It takes 2 arguments: Node: Type, Taxonomy: Term.
Node content settings:
- Node types: top
- Build modes: Full node
- Default argument: [field_content_type-raw]/[term-raw]
- Show title: No
Failed to work with node of type top with cck field content_type-raw and a term assigned.
Comment #13
Sam Dark CreditAttribution: Sam Dark commentedYou are not using views_attach_get_arguments_from_token_string() anywhere passing $node->nid argument as it was in original Views attach. At least patching against http://ftp.drupal.org/files/projects/views_attach-6.x-1.x-dev.tar.gz gave me that.
Comment #14
Sam Dark CreditAttribution: Sam Dark commentedpre_execute() in views_attach_plugin_display_* seems to work with previews only.
Comment #15
Sam Dark CreditAttribution: Sam Dark commentedActual displayed view (not a preview) getting parameters in views_attach.module in views_attach_user() for user and views_attach_nodeapi() for nodes.
Comment #16
agentrickard@Sam Dark
Your reports are too scattered to be helpful. The pre_execute() is the appropriate place to make the change. The issue is likely in the order in which arguments are replaced.
The assumption of the patch is that the "real" argument being passed is the NID or the UID. This is then exposed to token replacement by passing the _entire_ $node object (line 169 of the plugin file).
Notice that in hook_nodeapi(), we do not pass argument strings from the URL. We pass the NID directly from the node.
There may be some logic errors in how $this->view->args is being handled, but the patch is working fine for me, preview mode or regular.
Comment #17
agentrickardArgument by node type works for me.
Make sure you have the 'node types' selected appropriately (the replacement won't run for non-selected node types), and use [type] instead of [field-content-type-raw].
/me goes to test the taxonomy part.
Comment #18
agentrickardThere was an array handling error in the pre_execute(). Attached is revised patch.
Comment #19
agentrickardMight help if we updated the User token functions, too.
Comment #20
garyabbott CreditAttribution: garyabbott commentedThis patch is just what I needed to really take advantage of views_attach. I can now assign a hidden field in a overview node to select taxonomy terms for listing all relevant nodes as part of the overview node.
You do have a bug in the pre_execute routine for both node and profile that cause only the first digit of the argument to be used.
$user = user_load($args[0]); and $node = node_load($args[0]); both return single digit nodes based on the first digit of the argument. (node 35 becomes node 3) I dropped the [0] and got it working, but that may not be the correct solution if there are multiple arguments.
Comment #21
agentrickardHm. I stopped needing this patch and defer to Crell.
Comment #22
Crell CreditAttribution: Crell commentedRe garyabbot: The proper solution there would be to check the type of $args, and then pass it differently if it's an array or a string. Although I don't quite get why it is sometimes a string and sometimes an array. Hm, that may be something to ask merlin.
Comment #23
Crell CreditAttribution: Crell commentedI really want this to happen. :-) Tagging accordingly.
Comment #24
eabrand CreditAttribution: eabrand commentedHere's the patch with the fix recommended by Crell
Comment #25
eabrand CreditAttribution: eabrand commentedso this is tested. I think it works but I'm still a beginner so I only tested it as much as I could.
Comment #26
Crell CreditAttribution: Crell commentedThere was one line missing from the patch in #25 in hook_nodeapi, so I pulled that out of a previous version of the patch and committed it. Great work, everyone! The awesomeness of this module just increased dramatically. :-) So much so that as of this patch I am making a 2.x branch.
Comment #27
Crell CreditAttribution: Crell commentedComment #28
Crell CreditAttribution: Crell commentedActually I just found a number of problems with the patch after I committed it. :-( The major one is that the base table is NOT what we want to use as the token type, because you can have a node view attached to a user or a user view attached to a node. Just an FYI, I've fixed these in the 2.x-dev.
Comment #29
Dane Powell CreditAttribution: Dane Powell commentedI'm running 6.x-2.x-dev, and I think something is not quite right (or else I don't understand how to use this) - I added a Token default argument for Node Content, and then added an argument to actually do some filtering with, but it's not working - it would appear that the argument is still getting pulled from the URL rather than from the default token.
Comment #30
Crell CreditAttribution: Crell commentedIn the 2.x branch, the nid or uid is *always* what is passed into the view as an argument. It's then mutated into the appropriate value by token before being passed to the argument handler. If that's not working properly, please open a new issue rather than posting on one marked fixed.