I have created a patch that creates a reverse link on the user record for nodes that use the userreference field. With this you can see a link on the cck node that links to the user records, then find a link on the user record that links back to the cck node.

Comments

karens’s picture

I see that JonBob has changed the database structure again :-) This patch won't work any more in the latest cvs version of cck. I'll see if I can figure out how to make it work in the new structure.

By the way JonBob, I like the new db structure -- putting the node info back together instead of in separate tables makes sense and will be much easier to find, import, export, etc. At the moment though all my node views are empty and so my 'manage fields' page has no fields showing. Maybe something more is still on the way? In the meantime I'll try to figure out how the new system works.

karens’s picture

StatusFileSize
new1.87 KB

OK, this wasn't so bad after all. Attached is the patch that works in the new db structure. (And my problems with the node view and table fields not showing up was taken care of when I cleared my cache).

For anyone who hasn't already figured this out, if you don't have the latest db changes, update your module files to the latest version, then go to update.php and you will see that there are updates to apply. Apply them, then clear your cache (the part I missed) and you will be good to go on the changes.

jonbob’s picture

Sorry about that; I should have cleared the cache as part of the update. I will try to remember that in the future.

jonbob’s picture

I'd like to apply this, as this feature used to exist and it is needed. However, we need to figure out the best way to not force it on users; I can see cases where this information would get in the way. Perhaps we can find a way to be able to theme it out somehow?

karens’s picture

I realized that, too. I am re-writing the patch to add a widget settings option where you can elect whether or not you want to have a reverse link. Will post it later today.

Patrick Nelson’s picture

Hi Karen,

As it stands, this patch doesn't work (for me). I've added a content type that includes a user reference field. I've created it, autocompleted / added a user and then gone to view that user's profile but there is no link in their profile at all.

Am I missing something or does this not work with version 1.22 of the userreference module?

Regards

Patrick

karens’s picture

There were a bunch of changes made to both userreference and content and I see it no longer works. I will investigate...

karens’s picture

StatusFileSize
new2.63 KB

I was wrong, it was another change I had made that I was seeing. It *should* work. I re-rolled the patch to add in the ability to select whether or not to use the reverse links (it's an option when you create/edit the field). The default is off, so you have to turn it on if you want to see the link.

See if you still have problems...

karens’s picture

StatusFileSize
new2.37 KB

I got to thinking about this more and changed the approach. I was loading the user record only if you select a reverse link, but I think the userrefence field should always load the user record because other modules might want to use this info and/or it might be needed in themes. We don't want other modules to need to check if the user record is loaded and provide their own logic to do that, it makes more sense to just automatically have that info available.

I am working on a separate module that will provide additional functionality to make a cck node act as the user profile. I started to add that into the userreference field and then decided that it made more sense to make it a separate module that you can elect to use or not use. Anyway, that module needs the user record loaded, and it gets too confusing if sometimes it is loaded and other times it is not. I'll post that separate module shortly (it's *very* rudimentary right now).

Here is the re-rolled userreference patch.

karens’s picture

StatusFileSize
new2.44 KB

Re-rolled again. I didn't like the format of the loaded object -- it was unnecessarily confusing if you need to access it from a theme or another module. I think this implementation is cleaner.

Sorry for all the confusion :-(

moshe weitzman’s picture

Status: Needs review » Needs work

i noticed that the comment "Implementation of hook_field_settings()" does not match the 'widget' settings function name.

killes@www.drop.org’s picture

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

I've changed the function _content_types to content_types, I've changed the coding style a bit and fixed the comment to match the function name. The patch is against 4.7

killes@www.drop.org’s picture

Version: 6.x-1.x-dev » 4.7.x-1.x-dev
StatusFileSize
new2.84 KB

fixed bug: don't load nodes by vid, but by nid.

Nodes are now grouped by node type.

Should we order the nodes in some way?

moshe weitzman’s picture

whats the consensus on this? do we want it?

dkruglyak’s picture

+1

I suggest we commit it or at least update the patch to latest 4.7 CCK.

karens’s picture

I'd like to get this in, but just haven't had time to test it against latest version. If someone has time to test and mark it RTBC, I'll commit it.

dkruglyak’s picture

I am happy to help test this, but the latest patch is out of sync with the latest userreference.module.

If someone knows how to re-roll it (or better give me patched userreference.module file) I will try it out.

karens’s picture

Status: Needs review » Fixed

It took a very long time to get to this, but I've added this feature to the 5.x and HEAD versions.

karens’s picture

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

Changing version to reflect what was done. The original issue was for 4.7, but I didn't go that far back-porting it.

karens’s picture

I used killes' patch but forgot to credit him in the commit. Sorry killes!

As to the question about ordering the related nodes, that could be a separate issue. It may require another option in the widget settings where you select what order you want the nodes in.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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