Create a folder usercount in the location:sites/all/modules/
Create a file usercount.info in the location:sites/all/modules/usercount and add tho following code
name = User Count description = Field API to add fields to entities like nodes and users. package = Custom Block version = VERSION core = 7.x configure = admin/structure/usercount ; Information added by drupal.org packaging script on 2012-02-01 version = "7.12" project = "drupal" datestamp = "1328134560"
Create a folder usercount.module in the location:sites/all/modules/usercount/
<?php /** * @file * Enables the use of personal and site-wide contact forms. */ /** * Implements hook_help(). */ global $uerr; $_FILES; function usercount_help($path, $arg) { switch ($path) { case 'admin/help#usercount': $output = ''; $output .= '<dl>'; $output .= '<dt>' . t('View total user') . '</dt>'; $output .= '</dl>'; return $output; case 'admin/structure/usercount': $output = '<p>' . t('View total user') . '</p>'; return $output; } } function usercount_block_info() { $blocks['usercount'] = array( 'info' => t('View Total User') ); return $blocks; } function usercount_block_view($delta='') { $block = array(); switch ($delta) { case "usercount": $block['subject'] = t("View Total Product "); $block['content'] = drupal_render(drupal_get_form('usercount_block_contents')); break; } return $block; } function usercount_block_contents($form, &$state) { $result = db_select('users') ->fields('users') ->execute(); $count = count($result->fetchAll()); $form = array(); $path = drupal_get_path('module', 'usercount'); // Attach the CSS and JS to the form $form['#attached'] = array( 'css' => array( 'type' => 'file', 'data' => $path .'/demos.css' ), 'js' => array( 'type' => 'file', 'data1' => $path .'/jquery-1.7.2.js', 'data2' => $path .'/jquery.ui.core.js', 'data3' => $path .'/jquery.ui.accordion.js', 'data4' => $path .'/jquery.ui.mouse.js', 'data5' => $path .'/jquery.ui.resizable.js', 'data6' => $path .'/jquery.ui.widget.js' ), ); $form['table'] = array( '#prefix' => '<div id="footer"><p>Total users: '.$count ); $form['tableend'] = array( '#suffix' => '</p></div>' ); return $form; } ?>
Add this files demos.css,jquery-1.7.2.js,jquery.ui.widget.js,jquery.ui.resizable.js,jquery.ui.core.js in the location:sites/all/modules/usercount/
Total : 26654
Today :3
Today Visit Country :