Hi Guys.

I'm really liking the look of this module, although I'm struggling to get it to work in the way that I want. I've searched the forums with no luck, but I'm pretty sure this module can do this - I just don't know the syntax, etc..

My problem is this:

I am using a view to populate the nodereference explorer browser associated with a cck nodereference field, and I want to pass in a dynamic argument to my view. The argument I want to pass in is organic group context of the node currently being edited.

How do I do this?

If it's not possible could anyone suggest another way of doing it.

My head hurts. Any help GREATLY appreciated.

Aaron

Comments

just_fixed_it’s picture

Okay ... I may be wrong but investigation of the code has led my to think this module does not support dynamic arguments. I may be wrong. I do hope I'm just being thick

I have very little experience of javascript, but from what I see when a node is being edited and the 'Browse' button is clicked it launches a js window with content from the function

'nodereference_explorer_dialog' with arguments 'node_type' & 'field name'.

As I understand it, at this point in the code you can't get hold of node id, or group context etc. Can I maybe pass extra data (e.g. group id) as a "path argument" in the 'target address' of the button? Then I can access it and shove it into the php view class. Not hacky at all ... ;-)

As you can see I'm a greatly confused individual ...

HELP!

just_fixed_it’s picture

Hello? Anybody?

just_fixed_it’s picture

Right, so it's only me then ...

And in the light of no 'proper' fix ...

Okay, for anyone looking for a similar solution and happy to hack this module I've got it working, for my limited use.

It requires 2 dirty hacks:

Hack part 1:
file: nodereference_explorer\includes\nodereference_explorer.widget.inc
line: 118
code:
$group_node = og_get_group_context();
if ( $group_node!==NULL )
$field_settings['dialog'] .= '/'. $group_node->nid;

Hack part 2:
file: nodereference_explorer\includes\nodereference_explorer.menu.inc
line: 124
code:
$field['advanced_view_args'] = $title;

It's VERY dirty, and I'm not quite sure what the title argument is supposed to be there for but I've hijacked it to pass in the organic group.

Properly nasty, and I'n sure it'll blow up in my face later on ... but it's working right now, and I can sort out all my other problems ;-)

If anyone comes up with the proper way to sort this out I would be keen to find out.

Cheers,
Aaron

spacereactor’s picture

just_fixed_it can you provide a more detail on how to fix it, by using line 118 and line 124 doesn't work if the module is actively updated doesn't work, my sites just break after i insert the two hacks. Can you provide some line of code before and after the insert the hack.

just_fixed_it’s picture

This was a dirty hack, and I'd strongly recommmend coming up with a better way, but for your info ...

I've placed HACK 1 in the function 'nodereference_explorer_widget_process' after the line "$field_settings = array( ... SOME STUFF ... );"

I've placed HACK 2 in the function 'nodereference_explorer_get_overlay_content'. It's placed as the first line of the function definition after the opening brace.

gnindl’s picture

Status: Active » Needs review

The NRE module is just a widget. Any data processing is delegated to the underlying nodereference module. Therefore I'd recommend to have a look at the following issues which deal with dynamic view arguments, either tokens or PHP execution:

- #196518: Token support for advanced view argument
- #334121: Add PHP code textarea for 'views argument' in nodereference.module fields

I haven't tested these solutions, but I think that's the way to go. If you found a working solution, all you have to do is the following:

- Go your content type, edit the field settings "View arguments" with a proper token provided by OG or with PHP code as proposed in comment 3
- Add an additional argument to the NRE view

@just_fixed_it: please have a look if it works out for you and come back to this issue to hopefully close it successfully :)

gnindl’s picture

Project: Nodereference Explorer » Content Construction Kit (CCK)
Version: 6.x-1.1-rc5 » 6.x-2.x-dev
Component: Miscellaneous » nodereference.module
Status: Needs review » Active

Passing dynamic arguments to views query should be done by tokens in the nodereference module. Therefore this bug will be posted in the CCK issue queue. See also #196518: Token support for advanced view argument.