Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 737985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:47:05+00:00 2026-05-14T07:47:05+00:00

I am trying to 1) implement the hook menu and variable_set in the block

  • 0

I am trying to
1) implement the hook menu and variable_set in the block hook and to solicit and store configuration values from user,
2) then use retrieve configuration values and
3) pass them out into a template using theme hook when page is shown.

However I need a bit of a push on step two and three!

// =====================  file: my_module.php

function my_module_block($op = 'list', $delta = 0, $edit = array())
{
 switch($op)
 {
  case 'list':
   $blocks[0] = array(
   'info' => t('Find Something'), // required value - this shows up in your list of blocks
   'region' => 'left',             // default region on the page
   'weight' => 0,                  // position the block vertically within its column. 
   'visibility' => 1,              // permit the block to be displayed for a given user.   
   'status'   => TRUE,    // enabled
   );
   return $blocks;
   break;

  // case configure
  case 'configure':
    // not used ?

  // case save (save configuration values)
  case 'save':
   variable_set('my_module_text_bottom', $edit['my_module_text_bottom']);
   variable_set('my_module_text_top', $edit['my_module_text_top']);
   break;
 } 
}

function my_module_menu(){
  $items = array();

  // add menu items
 $items['my_module'] = array(
 // add a menu item here...
  );

  // administration setting - callback my_module_admin
  $items['admin/settings/my_module'] = array(
    'title' => 'Lookup on Something',
    'description' => 'Description of my module settings page',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('my_module_admin'),
    'access arguments' => array('access administration pages'),
    'type' => MENU_NORMAL_ITEM,
   );

  return $items;
}

// setup administrative default values (see: site configiration)
function my_module_admin() {
  $form = array();

  $form['my_module_text_top'] = array(
    '#type' => 'textarea',
    '#title' => t('Text of top of page'),
    '#default_value' => variable_get('my_module_text_top', 'my_module_text_top: This is configurable text found in the module configuration.'),
    '#size' => 1024,
    '#maxlength' => 1024,
    '#description' => t("text above the Find a Retailer block."),
    '#required' => TRUE,
  );


  $form['my_module_text_bottom'] = array(
    '#type' => 'textarea',
    '#title' => t('Text at bottom of page'),
    '#default_value' => variable_get('my_module_text_bottom', 'my_module_text_bottom: This is configurable text found in the module configuration.'),
    '#size' => 1024,
    '#maxlength' => 1024,
    '#description' => t("text below the Find a Retailer block."),
    '#required' => TRUE,
  );
  return system_settings_form($form);
}


// registering a theme
function my_module_theme(){
 return array(
  'my_module_show' => array(
  'arguments' => array('content' => "hello"),      
  'template' => 'my_module_show'
  ),
 );
}

// implementing a theme
function theme_my_module_show($content){
 $output = '<ul>$content</ul>';
 return $output;
}

function my_module(){
 $output = ''; 
 $variables = "";

 $output .= theme('my_module_show', $variables); 
 return $output; 
}

// =====================  file: my_module_show.tpl.php
print $text1;
print $text2;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T07:47:06+00:00Added an answer on May 14, 2026 at 7:47 am

    I adjusted your code a bit, with some comments in it. Hope that helps you out.

    
    function my_module_theme(){
     return array(
      'my_module_show' => array(
      'arguments' => array('text1' => NULL, 'text' => NULL), // define all arguments, no values required, keys serve as labels in theme function/template     
      'template' => 'my_module_show'
      ),
     );
    }
    
    
    function my_module(){
     $output = ''; 
    
     //use variable_get
     $text1 = variable_get('my_module_text_top', '');
     $text2 = variable_get('my_module_text_bottom', '');
    
     $output .= theme('my_module_show', $text1, $text2); //pass values as arguments to theme functions 
     return $output; 
    }
    

    For further reference :
    http://api.drupal.org/api/function/variable_get/6
    hook_theme (also in the api)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 357k
  • Answers 357k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The other answers are correct. Here is some code you… May 14, 2026 at 9:40 am
  • Editorial Team
    Editorial Team added an answer you ruin the noConflict concept by reassigning the jquery to… May 14, 2026 at 9:40 am
  • Editorial Team
    Editorial Team added an answer If you get that particular error, you don't actually have… May 14, 2026 at 9:40 am

Related Questions

No related questions found

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.