How to display the output of my module without clearing cache and refresh page?

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.

This article was republished from its original source.
Call Us: 1(800)730-2416

Pixeldust is a 20-year-old web development agency specializing in Drupal and WordPress and working with clients all over the country. With our best in class capabilities, we work with small businesses and fortune 500 companies alike. Give us a call at 1(800)730-2416 and let’s talk about your project.

FREE Drupal SEO Audit

Test your site below to see which issues need to be fixed. We will fix them and optimize your Drupal site 100% for Google and Bing. (Allow 30-60 seconds to gather data.)

Powered by

How to display the output of my module without clearing cache and refresh page?

On-Site Drupal SEO Master Setup

We make sure your site is 100% optimized (and stays that way) for the best SEO results.

With Pixeldust On-site (or On-page) SEO we make changes to your site’s structure and performance to make it easier for search engines to see and understand your site’s content. Search engines use algorithms to rank sites by degrees of relevance. Our on-site optimization ensures your site is configured to provide information in a way that meets Google and Bing standards for optimal indexing.

This service includes:

  • Pathauto install and configuration for SEO-friendly URLs.
  • Meta Tags install and configuration with dynamic tokens for meta titles and descriptions for all content types.
  • Install and fix all issues on the SEO checklist module.
  • Install and configure XML sitemap module and submit sitemaps.
  • Install and configure Google Analytics Module.
  • Install and configure Yoast.
  • Install and configure the Advanced Aggregation module to improve performance by minifying and merging CSS and JS.
  • Install and configure Schema.org Metatag.
  • Configure robots.txt.
  • Google Search Console setup snd configuration.
  • Find & Fix H1 tags.
  • Find and fix duplicate/missing meta descriptions.
  • Find and fix duplicate title tags.
  • Improve title, meta tags, and site descriptions.
  • Optimize images for better search engine optimization. Automate where possible.
  • Find and fix the missing alt and title tag for all images. Automate where possible.
  • The project takes 1 week to complete.