Mercurial > defr > drupal > noderef_view
diff noderef_view.module @ 2:25a0c2fcbcfb
Don't wrap the field in a div, it may cause problems.
Instead, we just go back in the DOM 'till we find the div holding the
real data. It's not really all that good, but, it seems to do the job.
author | Franck Deroche <franck@defr.org> |
---|---|
date | Fri, 23 Jan 2009 18:57:45 +0100 |
parents | 71a07534c366 |
children | 9372c6448311 |
line wrap: on
line diff
--- a/noderef_view.module Fri Jan 23 17:03:10 2009 +0100 +++ b/noderef_view.module Fri Jan 23 18:57:45 2009 +0100 @@ -110,10 +110,15 @@ */ function noderef_view_alter_item(&$form, $key, $field) { if (is_array($field) && $field['type'] == 'nodereference') { - list($link, $id) = _noderef_view_get_link($field); + $link = _noderef_view_get_link($field); if (!empty($link)) { - $form[$key]['#prefix'] .= "<div id='noderef_view_link_{$id}'>"; - $form[$key]['#suffix'] = $link .'</div>'. $form[$key]['#suffix']; + $suffix = $link; + if (isset($form[$key]['#suffix'])) { + $form[$key]['#suffix'] = $suffix . $form[$key]['#suffix']; + } + else { + $form[$key]['#suffix'] = $suffix; + } return TRUE; } } @@ -128,7 +133,6 @@ * - Une chaine vide sinon */ function _noderef_view_get_link($field) { - static $id = 0; $path = ''; // Check if there's a view associated with this field if (isset($field['advanced_view']) && $field['advanced_view'] !== '--') { @@ -139,22 +143,19 @@ if (is_array($display->display_options) && isset($display->display_options['path'])) { $path = $display->display_options['path']; - break; + break; } } } // If we found a view with a suitable display, then link to it if (!empty($path)) { - $id++; popups_add_popups(); $options = array( - 'attributes' => array( - 'class' => 'popups noderef_view_link', - 'rel' => 'noderef_view_link_'. $id), + 'attributes' => array('class' => 'popups noderef_view_link'), 'query' => array('destination' => 'node') ); $path = l(t('Search'), $path, $options); } - return array($path, $id); + return $path; }