You are here

function _disqus_ds_comment_count in Disqus 7

Display the DS comment count for a node

1 string reference to '_disqus_ds_comment_count'
disqus_ds_ds_fields_info in disqus_ds/disqus_ds.module
Implementation of hook_ds_fields_info().

File

disqus_ds/disqus_ds.module, line 60
Drupal module that adds Disqus support to Display Suite.

Code

function _disqus_ds_comment_count(array &$field) {
  $entity = $field['entity'];
  if (isset($entity->disqus) && $entity->disqus['status']) {
    $settings = array(
      'disqusComments' => $entity->disqus['domain'],
      'disqus' => $entity->disqus,
    );
    $render = array(
      '#theme' => 'link',
      '#text' => t('Comments'),
      '#path' => 'node/' . $entity->nid,
      '#options' => array(
        'attributes' => array(
          'data-disqus-identifier' => 'node/' . $entity->nid,
          'fragment' => 'disqus_thread',
        ),
        'html' => false,
      ),
      '#attached' => array(
        'js' => array(
          array(
            'data' => drupal_get_path('module', 'disqus') . '/js/disqus.js',
            'type' => 'file',
          ),
          array(
            'data' => $settings,
            'type' => 'setting',
          ),
        ),
      ),
    );
    return drupal_render($render);
  }
  return;
}