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.


Assigned:Unassigned» Sam Dark

I'm going to implement it this week.

Status:Active» Needs review
new6.16 KB

Made a patch (against DRUPAL-6--1) that integrates Views attach with powerful Token making it possible to pass virtually any arguments to views.

new11.47 KB

This 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.

new11 KB

Thank you for this patch.

I've merged it with my latest code and tested on development server.

@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.

new9.05 KB

@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().

new9.38 KB

Urk! Last patch was against the wrong svn revision.

It 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);

Sorry about that. Will test latest patch with my installation.

I 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.

new9.52 KB

The previous patch was overwriting non-token arguments.

Latest 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.

You 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 gave me that.

pre_execute() in views_attach_plugin_display_* seems to work with previews only.

Actual displayed view (not a preview) getting parameters in views_attach.module in views_attach_user() for user and views_attach_nodeapi() for nodes.

@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.

Argument 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.

new9.56 KB

There was an array handling error in the pre_execute(). Attached is revised patch.

Assigned:Sam Dark» Unassigned
new9.76 KB

Might help if we updated the User token functions, too.

This 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.

Status:Needs review» Needs work

Hm. I stopped needing this patch and defer to Crell.

Re 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.

Issue tags:+Release blocker

I really want this to happen. :-) Tagging accordingly.

Status:Needs work» Needs review
new12.8 KB

Here's the patch with the fix recommended by Crell

new11.3 KB

so this is tested. I think it works but I'm still a beginner so I only tested it as much as I could.

There 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.

Status:Needs review» Fixed

Version:6.x-1.x-dev» 6.x-2.x-dev

Actually 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.

I'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.

In 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.

Status:Fixed» Closed (fixed)
Issue tags:-Release blocker

Automatically closed -- issue fixed for 2 weeks with no activity.