Project:Node Reference Variables
Version:7.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:thorin_edr
Status:closed (fixed)

Issue Summary

Hi, great initiative with this module!

I've tested it locally, and looks to be working fine =)

About the suggestion, have you thought of moving this to a CCK formatter in the future? Seems to me it could be a good way to go!

I suppose the code would have to be more stable but hey, this is really new still. Just thought I'd drop the idea just in case =)

Comments

#1

Assigned to:Anonymous» greg.harvey

Hi. Thanks for the suggestion. I don't really know anything about CCK formatters yet, but it sounds like a perfectly sensible idea. Assigning to me. Can you suggest a module that might be a good current example of a CCK formatter for CCK 6.x-2.x?

#2

I know there are two hooks available, hook_field_formatter_info and hook_field_formatter  , but unfortunately the documentation for d6 does not include these two yet.

hook_field_formatter_info(): Declare information about a formatter.
hook_field_formatter($field, $item, $formatter, $node): Prepare an individual item for viewing in a browser.

This comment could also be useful perhaps.

My guess is better look at an example, even nodereference itself implements formatter_info, might be a good way to start.

Some other examples could be:
thickbox, and perhaps a more simple example could be imagefield

Let me know how it goes, looks to me that it's not as hard as it sounds, after seeing some examples :D

#3

I've been digging into cck formatters myself a bit, something I wanted to learn anyway, and this should get you started

<?php

/**
* Implementation of hook_field_formatter_info().
*/
function nodereference_variables_field_formatter_info() {
 
$formatters = array();
  if (
module_exists('tabs')) {
   
$formatters['tabs'] = array(
     
'label' => t('Display in tabs'),
     
'field types' => array('nodereference'),
     
'description' => t('Displays the referenced nodes in tabs using the tabs module.'),
    );
  }
  return
$formatters;
}


/**
* Implementation of hook_theme().
*/
function nodereference_variables_theme() {
 
$theme = array();
  if (
module_exists('tabs')) {
   
$theme['nodereference_variables_formatter_tabs'] = array('arguments' => array('element' => NULL));
  }
  return
$theme;
}

/**
* Theme function for displaying referenced nodes in tabs
*/
function theme_nodereference_variables_formatter_tabs($element) {
 
$output = '';
 
// do your magic here
 
return $output;
}
?>

Something along those lines should get what we want =) ---now Im not sure wether this should be provided by CCK, or tabs or what... hope it helps!

#4

Thanks for this - great start. To be honest, I don't have an opportunity to implement it for a little while as I have to get on with delivering the site I'm working on with what I have (deadlines are tight) but I will come back to this and finish it if I get time, either before I go on holiday or when I get back. =)

#5

As someone who has struggled with this topic, this would be GREAT. I'll watch for it on the module release feed!

#6

Just for future reference when you get to doing this, I've written up an article about how to create a cck formatter, take a look, I hope I wrote it clearly enough =) There is an example module attached to the article, implementing a couple of cck formatters for nodreference, you could just use that as a template if you want.

#7

Version:6.x-1.x-dev» 7.x-1.x-dev
Assigned to:greg.harvey» thorin_edr
Status:active» closed (fixed)

I'm not planning to do it for the D6 version, as it implies discarding code that is already tested and working fine.

However, the proposal makes a lot of sense and I liked the idea, so it's been implemented on the Drupal 7 version of the module. It needs a few extra bits to be more flexible, that will be implemented in the next days / weeks, but is now fully functional, so... go ahead and try it! ;-).

Therefore I'm moving to 7.x-1.x-dev, assigning to myself and closing. Please feel free to reopen if you like to add anything on the topic.

#8

Awesome news, thanks!