Simply add the following to the end of advpoll.module and the poll results will become a custom weighted field in the field display settings (if CCK is enabled).


function advpoll_content_extra_fields($type_name) {
  $extra = array();
  $types = advpoll_node_info();

  if (in_array($type_name, array_keys($types))) {
    $extra['poll'] = array(
      'label' => t('Poll Results'),
      'description' => t('Poll Results - this is purely for output weighting'),
      'weight' => 1,
    );
  }

  return $extra;
}

Once you have this in there, you can drag the results field to any position. Nothing will appear in the edit form, however if you have any custom fields (such as a node referrer field which lists any other nodes that reference the poll), you have some level of control on which appears first (rather than simply hard coding a weight of 2 to the results).

This is implemented on (and I guess therefore sponsored by?) http://www.sportbusiness.com/ (see http://www.sportbusiness.com/node/170225)

Comments

ChrisKennedy’s picture

Great stuff - thanks Nick :). I'm a bit swamped for the next month and probably can't really review or test any advpoll patches. I've given you commit access because your code is great and I don't want to be the bottleneck - feel free to commit good patches if I don't respond within a few days.

markus_petrux’s picture

Status: Needs review » Needs work

Actually, all the top level elements added to the form by advpoll that are not already supported by CCK would have to be added here as well, I think.

hook_content_extra_fields() would have to expose all items added to node view, but also all items added to node edit form. Otherwise, the form elements cannot be positioned correctly in the node edit form, and for example, "Menu settings" appear just below the "Binary question" field. This is worst when there are other elements added by CCK or other modules, even when they are exposed to CCK.

The problem is that CCK takes over the weights of all top level elements in the form, and the resulting value for these weights after the "Manage fields" screen is submitted is unknown. So all elements that are not exposed to CCK may end up at any position in the form.

miro_dietiker’s picture

OK then we'll need to expose all fields to the hook. Who's going to take the ball?
This hook should be implemented much more to have clean controle over the forms and output renderings.

gobinathm’s picture

Issue summary: View changes
Status: Needs work » Closed (outdated)

D6 is EOL hence this issue won't be fixed (or) attended. So closing it.