Hi,
I have a content type which has a nodereference field that is being displayed via cck_blocks. So I'm able to create self-references. When referencing any other node, the CCK Block displays it as a Teaser, which is what I told it to do. Self-referencing nodes are however being displayed as Title (link), which is actually not that correct ;)
I stepped through the code (not entirely, sorry) and it seems that the formatter is being rewritten from "teaser" to "default" somewhere inside nodereference.
I modified theme_nodereference_formatter_default() to the following to get a bit of an insight:
/**
* Theme function for 'default' nodereference field formatter.
*/
function theme_nodereference_formatter_default($element) {
$output = '';
if (!empty($element['#item']['nid']) && is_numeric($element['#item']['nid']) && ($title = _nodereference_titles($element['#item']['nid']))) {
$output = l($title, 'node/'. $element['#item']['nid']);
}
// I added this:
foreach(debug_backtrace() as $entry)
{
echo "\n -> ".$entry["function"];
foreach($entry['args'] as $arg)
{
if(is_array($arg) && isset($arg['#formatter']))
{
echo " (".$arg['#formatter'].")";
}
}
}
//
return $output;
}
The output is:
-> theme_nodereference_formatter_default (default)
-> call_user_func_array
-> theme (default)
-> drupal_render (default)
-> drupal_render
-> drupal_render
-> drupal_render
-> drupal_render
-> node_view
-> node_show
-> node_page_view
-> call_user_func_array
-> menu_execute_active_handler
-> theme_nodereference_formatter_default (teaser)
-> call_user_func_array
-> theme (teaser)
-> theme_nodereference_formatter_full_teaser (teaser)
-> call_user_func_array
-> theme (teaser)
-> content_format
-> call_user_func_array
-> module_invoke
-> cck_blocks_block
-> call_user_func_array
-> module_invoke
-> block_list
-> theme_blocks
-> call_user_func_array
-> theme
-> template_preprocess_page
-> call_user_func_array
-> theme
Best regards,
Lars
Comments
Comment #1
lgierth commentedI'm sorry I forgot that, my Drupal version is 6.12.
Comment #2
markus_petrux commentedThis is probably an issue with the CCK Blocks module.
Comment #3
Anonymous (not verified) commentedWhat's the status of this issue? Please try the newest -dev release.
Comment #4
lgierth commentedHi,
the problem still exists, I tried HEAD with drupal-6.14 and cck-2.5. Here's what I exactly did.
Let me know if you know need more information.
Best regards,
Lars
Comment #5
Anonymous (not verified) commentedCan you post a link where I can see that behaviour?
Comment #6
Anonymous (not verified) commentedThis is not a cck_blocks issue, as the behaviour is the same, if you display the node reference / self reference with the node itself. CCk blocks only displays the fields how they are renderend by cck.
Comment #7
Anonymous (not verified) commentedSorry, forgot the screenshot.
Comment #8
markus_petrux commentedWhat's the problem exactly?
Comment #9
lgierth commentedHi markus_petrux,
a nodereference field, whose value's nid and parent nid are the same will not display correctly.
I just noticed that this might be a mechanism to prevent the creation of infinite loops (a node displays itself displays itself displays itself, etc.).
Best regards,
Lars
Comment #10
markus_petrux commentedOh, I see. Well, yes there's such a check in the formatter of the nodereference field.
I think the current code is safe enough, so I would suggest overriding the theme function and here you can adapt the check to your own needs. See theme_nodereference_formatter_full_teaser() in nodereference.module.
Comment #11
lgierth commentedThanks!