Node Reference URL Widget is not compatible with OG 7.x-2.x-dev:

Fatal error: Call to undefined function og_get_context_by_url() in /***/nodereference_url/nodereference_url.module on line 178

Drupal 7.12
OG 7.x-2.x-dev

Similar issue:
#1475462: og_get_context_by_url() no longer exists in the og_context.module in og7.x-2x-dev. Organic Groups create permissions is broken

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

iRex’s picture

also getting the same problem. anybody found a work around?

thanx!

dtarc’s picture

The way OG 7.x-2.x is set up I don't think there's going to be an easy way to do this. However I don't think this code will work with OG 7.x-1.x either, as og_get_context_by_url() does not appear to be in there either.

The issue is that OG 7 uses EntityReference to make the group field, and it uses EntityReference Prepopulate to set the gid in the url.

Most of the time the group audience field will be called og_group_ref. Hoever, OG 7.x-2.x allows multiple group audience fields per entity, and so really these fields could have any machine name.

So I'm not sure how easy it will be for nodereference_url to automatically tack on group gids. It will require some thought, for sure.

For the project I'm using these two modules on, we aren't using the nodereference_url link autogeneration. We are using Display Suite and making custom display suite fields to display these links. For our purposes we don't need nodereference_url to know anything about og.

However even though we aren't using these auto generated links, the auto generation keeps running, and we get this fatal error. I thought of removing the og related code via a patch, but I noticed another bug.

Currently nodereference_url allows you to specify whether these links should be created for full or teaser nodes. However, even if this is set to disabled, the links get generated (causing this fatal error). You can track this issue here - #1571318: Node link settings booleans not being checked (I have added a patch with the fix).

Applying the patch linked in the above issue at least allows for turning the link generation off, eliminating the fatal error. Unfortunately you then need to come up with a custom solution to create the link yourself, if you would like the og group gid added.

Note: since OG 7.x-2.x uses EntityReference Prepopulate, this handles the setting of group gid. You don't need nodereference_url to do this. You only need to combine Nodereference URL with OG Group passing if you have a more complex use case.

Here is what we are using it for -

Node Type A is a group
Node Type B is a group post content type
Node Type C is a group post content type
Node Type C has a node reference to Node Type B

So, on Node Type B, we want a link that will load a Node Type C node add form, and autopopulate both a) the group audience field referencing to Node Type A, as well as the node reference field referencing Node Type B.

So we create custom links that look like this:
node/add/node_type_c/[node_type_b_nid]?og_group_ref=[node_type_a_nid]

Once the links are no longer being auto-generated, we are no longer having to deal with the bug.

Patribus’s picture

Was there some development for this issue?

xanks

ptitwolfy’s picture

Subscribing

Patribus’s picture

Hello, I'm repeating myself with this post, but again the question:

are there news concerning this subject?

Cheers

Oleksa-1’s picture

same issue and i think i am willing to migrate from nodereference to EntityReference to solve it.

Patribus’s picture

yes, I was thinking about the same thing... But as far as I understood it, EntityReference does not offer a fraction of the functionalities of NodeReference. Well, EntetyReference Propopulate to be more exact. The thing is, I do not really know it, since there is no real documentation for EntityReference Prepopulate (or is there one?)

Also I do not fully understand the differences between the Prepopulate and the EntityReference Prepopulate modules. Is there some place, where an overview of these modules + Node Reference URL are compared, described, etc?

Cheers

Oleksa-1’s picture

there is no real documentation for EntityReference Prepopulate

in readme.txt

also you can enable og_example in OG 7.x-2.x-dev to see how it works.

Open Social’s picture

+1 on comment #2.

I also think we should check if this function exists, because it will break your site when using OG 2.x branch..

Open Social’s picture

See attached patch. It will not fix the problem, but at least your site will not crash.

ishiomin’s picture

I am using Node Reference URL Widget with Answer Project . In my case, question and answer node type are group contents and users have created permission for this two type contents stricly in groups. The groups audience field is required and setting with entity reference prepopulate and with number of values illimited, a user can post a question in several groups. A user can post an answer with the url in the question if he has joined one or more groups of the question and the prepopulate answer is in the groups question subset. The code below is OK for my case :

      if (module_exists('og_context')) {
        // og_context must be set to use prepopulate
        // get array with audience groups of the question
        $entity_audience_groups = og_get_entity_groups('node', $node->nid);
        $comma = '';
        $audience = '';
        foreach ($entity_audience_groups['node'] as $entity_audience_group)  {
	  // check if user as permission for each group and create the possibles groups list 
          if (og_user_access('node', $entity_audience_group, 'create answer content' )) {
            $audience .= $comma . $entity_audience_group ;
            $comma = ',';
          } 
        }
        if ($audience == '') {
           // user has not create answer permission in any question groups
          $link = NULL;		
        }
		else {
          // the audience field machine name is hard code
          $link['query']['og_group_ref'] = $audience;
		}		
      }
bsandor’s picture

#10 patch looks to be working for me

afdigital’s picture

#10 patch works for me too. The site seems to work fine enough after applying the patch.

ssoulless’s picture

Status: Active » Postponed

It works for me, but well see for production sites... if someone could fix the problem with this patch and is in a production environment please post it here, then the issue will be closed after not...

ssoulless’s picture

Status: Postponed » Closed (fixed)

I already use the patch in a production site, the maintainers should comit it. Now the issue can be closed

thomas.fleming’s picture

Issue summary: View changes
Status: Closed (fixed) » Needs review

I agree that this patch needs to be committed, but it also needs to be tested first. Setting to needs review for testing.

thomas.fleming’s picture

Since Organic Groups 7.x-1.x isn't a supported release anymore, I created a new patch that should make Node Reference URL Widget compatible with Organic Groups 7.x-2.x.

ssoulless’s picture

Priority: Normal » Major
Status: Needs review » Reviewed & tested by the community

Tested in my dev site, Not sure what can happen, in a production site, how ever it should works fine in a production site too...

Thanks for the patch tidrif

ggevalt’s picture

Have to say that it's very sad that this module is not working right. Since we are using OG, it does not play well. Basically it breaks the parent content type. I appreciate the effort with the patch, but it so far looks untested and we can't take a chance.

The references and node reference url widget worked really well in D6. We used it in all are sites for several different functionalities and it is a shame to have lost it. We now have to move to D7. Entity reference and Entity reference prepopuate don't do the same thing and folks' suggestions on how to emulate the Node Reference URL widget, while well meaning, would have made Rube Goldberg proud -- and for those of you who don't understand that reference, Goldberg was a cartoonist who devised intricately complex machines to do a simple task.

Since we need to move forward, we are, sadly, going to have to abandon the references modules, including this one and try to fashion something that works almost as well out of the entity reference modules as this is the course of Drupal, we don't have much time left to complete our task and this fine module seems inoperative with OG.

I want to thank all of you who've put so much effort into the D6 modules. This is one of those changes that weren't for the better and it's too bad that these modules got nosed out by the D7 preference for entity references which seem far more complicated and less robust.

Thanks again for your efforts.

katche’s picture

hi

where exactly do i have to put in the file in patch #10?

thanks for helping!
Katharina

matt.rad’s picture

Can we get this committed please?

krutibhakta’s picture

Thank you patch #10 works.