I noticed that the link on the referencable content type disappears if it's a group postable node. Attached is a 4 line patch that fixed it for me. Take a look and let me know what you think.

Comments

snorkers’s picture

I ran the patch and received a 'patch unexpectedly ends in middle of line' error, although the patch seemed to run by looking at the text content.

However, not sure how to structure the URL: I expected this to work, but it didn't

/node/add/listing/NID?gids[]=3462

I also tried /node/ognodeadd/NID?type=listing&gids%5B%5D=3462

Where listing is my [OG post] content type, and NID was my node ID of the referencable content. Have I structured the URL correctly?

WorldFallz’s picture

StatusFileSize
new1.06 KB

Here's a new version of the patch-- I didn't realize the query parameter could be an array. This should be "more correct".

I can confirm the following URL works with this patch, not sure about the previous one though:

http://example.com/node/add/{content-type}/{nid}?gids[]={group-nid}

snorkers’s picture

Status: Needs review » Needs work

I reapplied the v2 patch - it's applied, although during the patch process a 'patch unexpectedly ends in middle of line' error is generated. Patched against current release 6.x-1.3

Although the OG context is passed, the node being referenced is not (ie not being prepopulated).

The new 'add referencing node' link is structured: ../node/add/{content-type}/{nid}?gids[]={og nid}. But because adding OG nodes change any URLs /node/add/{content-type}?gids[]={group-nid} to format of node/ognodeadd/?type={content-type}&gids[]={group-nid{, the hook_widget() in the module will not recognize the NID and adopts the fallback behavior. It looks like the easiest way may be to change this module so that a query parameter is passed for the referenced node, rather than building the URL. No idea whether this will work without clean URLs..?

I've played around with the v2 patch - with destinations on and off. As soon as gids[] is added to the query (regardless of any other parameters), the node referencing will not work.

Not sure a clean patch will come from this...

snorkers’s picture

Status: Needs work » Needs review
StatusFileSize
new2.23 KB

Had a little play and this patch now works for me as it builds an create OG post URL using node/ognodeadd/... structure, and built in a special case check in nodereference_url_widget() function.

Reviewers be gentle - my first patch (yay!).

khad’s picture

patch v3 gives a page not found error, but patch v2 seems to work for me - both group and referenced node get prepopulated

quicksketch’s picture

Status: Needs review » Fixed
StatusFileSize
new763 bytes

I also couldn't get #4 to work, but #2 seemed pretty close so I started with that patch. The only problem with it was that drupal_get_destination() will not work with the array structure query string, so I had to convert it back to being a concatenated string. I tested out this patch and it seems to work as desired.

I also made one other large change which was replacing og_get_group_context() with og_determine_context_get_group($node). This approach seemed safer because it took the $node object as a parameter, so it should work properly when showing a list of nodes which may not necessarily be in the same group.

quicksketch’s picture

Title: link doesn't take into account og context » Link doesn't take into account Organic Group context
snorkers’s picture

I think the v3 version doesn't work unless you've got og_user_roles module too (which changes the URL structure for new nodes). Sorry for confusion. My bad

Status: Fixed » Closed (fixed)

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

snorkers’s picture

Version: 6.x-1.3 » 6.x-1.5
Status: Closed (fixed) » Needs review

og_determine_context_get_group($node) does not seem to work for me - only og_get_group_context() adds the necessary gids[]=GROUP_ID parameter to the URL. (Line 140 in nodereference_url.module)

My apologies for a late reply to this. Took a while to rebuild site on version 4 of OG User Roles (which has a correct URL construct for adding new nodes - see comments #4 and #8), before I could update to latest version of nodereference_url

quicksketch’s picture

Status: Needs review » Fixed
StatusFileSize
new1.25 KB

Thanks for the report snorkers. I think that it depends on your use-case which function is going to work for you. If you're on a page that doesn't have an OG context (like the Front page), then og_get_group_context() isn't going to work. However if the node that is being referenced isn't in a group, then og_determine_context_get_group($node) won't work.

So a good solution here is to try both. I decided to use og_get_group_context() first, since you'll usually be adding nodes to the group you're currently looking at (if any), then fallback to checking the node that you're referencing as the desired group. Please let me know if this works for you and I'll make a new release. Set back to needs work if this doesn't work.

snorkers’s picture

Thanks Nate

Simple solution and works just fine - sorry for not thinking a little harder before posting... should have thought of that.

Status: Fixed » Closed (fixed)

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

snorkers’s picture

Status: Closed (fixed) » Fixed

Fixed in release 6.x-1.6

Status: Fixed » Closed (fixed)

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

jippie1948’s picture

Version: 6.x-1.5 » 6.x-1.6

Hi,

I still seem to have the above problem with a node that is related to one or more groups. If not, everything works as intended.

When I click the Add button, some activity seems to take place but visually nothng happens.
When I hover over the Add button the following URL appears:
mysite/en/node/add/image/477?desitnation is node/477&gids[]=364

Looking forward to haring form you.

JanPieter.

jippie1948’s picture

My apologies: Apparently I had a senior moment when reading late at night this issue. I missed the problem with the OGUR old version.

After had installed version 4.1 the problem disappeared. :-)