Active
Project:
NodeReferrer
Version:
6.x-1.0-rc2
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
23 Feb 2011 at 18:50 UTC
Updated:
2 Aug 2011 at 00:22 UTC
Would be great if you could add more formatters including the nid and path so that we can rewrite the field to create whatever title we want for the link or some other behavior. THANKS!
Comments
Comment #1
migimaru commentedI needed this feature in my current project (using Views), so I ended up creating a subclass to override some functionality, but I think it would be better if this were included in the module itself. I'm not familiar with creating patches, but here's what I would propose, based on what I did:
* Add a boolean argument to nodereferrer_referrers() that determines whether to include the nodereferrer's content fields. If TRUE, then $select_field .= ", nr.*" (This would only get the fields that are stored in the same table, but it's a start.) Then in the while loop, instead of only setting the nid, vid, and title, use a foreach loop to set all of the result array values.
* In nodereferrer_referrers_with_translations(), add the same argument to be passed along to nodereferrer_referrers().
* In the nodereferrer_view_handler_field class, add a form option for this setting. In referrers(), pass that value in the nodereferrer_referrers_with_translations() call.
* Also in the options_form() function, instead of using the nodereferrer_field_formatter_info() function to get the list of formatters, call _content_type_info() and get all the formatters available for the 'nodereferrer' field type.
This way, the user can create custom modules that add new formatters with hook_field_formatter_info() and hook_theme(), and those formatters can have access to the referring node's fields (at least some of them).
I didn't need the functionality outside of Views, so I'm not sure what else needs to be done (probably just adding the option to the field settings form and adjusting the nodereferrer_field() call?)
Comment #2
andypostSuppose you should use you custom or views module to implement this functionality
Comment #3
migimaru commentedThe problem is that you currently can't add your own formatters for Nodereferrer fields, since the form only allows the formatters specified in nodereferrer_field_formatter_info(). If you at least change that part of the module, then anyone can add their own formatters without having to touch the module code.
Comment #4
andypostYou should read docs about CCK and implement hook_field_formatter_info() in you custom module
Comment #5
migimaru commentedI already have. Even if I implement hook_field_formatter_info(), that formatter is not available in Views. Check the code in views/nodereferrer_view_handler_field.inc, line 19:
The only formatters that the module allows in Views are the ones defined in nodereferrer_field_formatter_info(). Instead, I propose that it be changed to: