Hi, utilizing the live chat as shown on your homepage. I have it working as you have described and it is awesome. However, I would really like to have the view live update when a question comes through. Currently, only the answer live updates. Is there a simple tweak to the code which will allow the view to live update everytime a new question comes in? Thanks a ton. Great work.

Comments

jonskulski’s picture

If you remove the check for the field_question_answer, you should have some luck. I haven't tested this, but it should work.

function live_update_chat_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  if ($op == 'presave' && $node->type == 'question') {
    if ($node->field_question_answer[0]['value']) {
      $html = node_view($node, TRUE, FALSE, TRUE);

      $settings = array(
        'target' => '#node-'. $node->nid,
        'method' => 'replaceWith',
      );

      live_update_update_content('live-update-chat', $html, $settings);
    }
  }
}

becomes:

function live_update_chat_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  if ($op == 'presave' && $node->type == 'question') {
      $html = node_view($node, TRUE, FALSE, TRUE);

      $settings = array(
        'target' => '#node-'. $node->nid,
        'method' => 'replaceWith',
      );

      live_update_update_content('live-update-chat', $html, $settings);
    }
  }
}

This will supply an update any time a question is saved or updated.

jonskulski’s picture

Status: Active » Closed (fixed)
tpainton’s picture

Excellent. Thanks for the post, I'll give it a try. If you have time was also wondering about enabling this for blocks as it only works on page view at present.

jonskulski’s picture

Status: Closed (fixed) » Active

TPainton,

For blocks the code would be similar except the live_update_initiialization call would be when the block was rendered and the live_update_content call would not be a full rendered node (as it is now).

I will be developing a blocks/panel panes version of this module so that should give you something more to go on.

tpainton’s picture

awesome. Thanks so much.

sittard’s picture

block +1