I created a very simple module which generates a tag cloud based on user input; you can see the code here.
// wow.module function wow_menu() { $items = array(); $items['wall/of/words'] = array( 'title' => 'Wall of Words', 'page callback' => 'wow_page', 'access arguments' => array('access content'), 'file' => 'wow.inc', 'weight' => 1, ); $items['admin/settings/wall/of/words'] = array( 'title' => 'On this date module settings', 'description' => 'Description of your On this date settings page', 'page callback' => 'wow_admin_page', 'page arguments' => array('wow_admin'), 'access arguments' => array('administer wow settings'), 'type' => MENU_NORMAL_ITEM, ); return $items; } function wow_admin_page() { return 'hey'; } // wow.inc function wow_page() { $output = array( 'form' => drupal_get_form('wow_cake'), 'words' => _getWords(), 'min_count' => 0, 'max_count' => 999 ); drupal_add_js(drupal_get_path('module', 'wow') . '/js/jquery.tagcloud.js'); drupal_add_js('jQuery(function(){jQuery("#wow-container .cloud a").tagcloud({size:{start:20,end:40,unit:"pt"},color:{start:"#46A7E3",end:"#0969A3"}})})', 'inline'); return theme('wow_template', array('output' => $output)); } function wow_theme($existing, $type, $theme, $path) { return array( 'wow_template' => array( 'template' => 'wow_template' ), ); } function wow_cake($form, &$form_state) { $form = array(); $form['title'] = array( '#type' => 'textfield', '#title' => t('Thank you for...'), '#size' => 60, '#maxlength' => 128, '#required' => TRUE, ); $form['buttons']['submit'] = array( '#type' => 'submit', '#value' => t('Submit'), ); return $form; } function wow_cake_validate(&$form, &$form_state) { if (empty($form_state['values']['title'])) { form_set_error('title', t('Please leave a thank you message in highlighted field below.')); } } function wow_cake_submit(&$form, &$form_state) { if (_create_node($form_state['values']['title'], $form_state['values']['title'])) { drupal_set_message(t('Thank you for your kind words!'), 'status'); } } function _getWords() { $query = new EntityFieldQuery(); $query->entityCondition('entity_type', 'node', '=') ->propertyCondition('status', 1, '=') ->propertyCondition('type', 'wall_of_words', '='); $result = $query->execute(); $nodes = $result['node']; $fields = field_info_instances('node', 'wall_of_words'); $field_id = $fields['body']['field_id']; field_attach_load('node', $nodes, FIELD_LOAD_CURRENT, array('field_id' => $field_id)); $wall = ''; foreach ($nodes as $node) { if (!empty($node->body['und']['0']['value'])) { $wall .= trim($node->body['und']['0']['value']); $wall .= " "; } } if (!empty($wall)) { $cloud = explode(" ", $wall); } return array_count_values($cloud); } function _create_node($title = "", $body = "", $language = "und") { $node = (object) array(); $node->type = 'wall_of_words'; $node->status = 1; $node->promote = 0; $node->sticky = 0; $node->revision = 0; $node->language = $language; $node->title = $title; $node->body[$language][0] = array( 'value' => $body, 'format' => 'full_html', ); if ($node = node_submit($node)) { node_save($node); } return $node; }
My issue: when I visit another page and come back to the page that I generated with my module the output of the content does not get displayed unless I clear the cache and visit the page again.