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

  • SEARCH
  • Home
  • 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 7560921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:01:53+00:00 2026-05-30T13:01:53+00:00

I am learning drupal and am trying to add some extra features to a

  • 0

I am learning drupal and am trying to add some extra features to a module I’ve made following a tutorial

I have one block ‘History’ which shows the last x pages you’ve viewed.

Now I’ve made a second block with a button ‘clear history’, but I can’t figure out how to make the set_value(‘trails_block_history’,’0′) happen when my button is clicked (which would clear my history in the database)

anybody who can help me out here?

My blocks:

    function trails_block_info() {
  $blocks['history'] = array(
    'info' => t('History'),
    'cache' => DRUPAL_NO_CACHE,
  );

  $blocks['clearHist'] = array(
    'info' => t('Clear history'),
    'cache' => DRUPAL_NO_CACHE
  );
  return $blocks;
}

hook block save:

function trails_block_save($delta = '', $edit = array()) {
  variable_set('trails_block_num', $edit['trails_block_num']);
  variable_set('trails_block_granularity',$edit['trails_block_granularity']);
}

and the problem:

function trails_block_view($delta = '') {    
...
case 'clearHist' :
      {
        $block['subject'] = 'Clear History';
        $block['content'] = '<button>clear history</button>';
      } break;  
...

Still a student and reaaally new to this (started the module-coding this morning) so sorry if this seems like a stupid question (which it most probably is) but I just can’t find it..

Have made another extra feature on the module allready, so I want this one to work as well!

  • 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-30T13:01:54+00:00Added an answer on May 30, 2026 at 1:01 pm

    You should use Forms API to create a form with submit button. Then clear your history when form is submitted. More info here and some example code here

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

Sidebar

Related Questions

I trying to write a drupal module. I'm following book Learning Drupal 6 Module
I'm a little new to drupal but have been using things like devel module
Learning CasperJS Trying to understand why the following is not displaying my results in
I started learning drupal customization, and i'm trying to create a very simply custom
learning Jquery and integrating with PHP - getting there, but have one last challenge
I'm learning Drupal to save some production time for my websites, but it looks
In my way of learning drupal, I got stuck in this issue. I have
learning html/css here. I'm trying to add a border-bottom to my .menu ul li
Learning C# here. I have a monthly process form whereby one can select to
Learning Scala currently and needed to invert a Map to do some inverted value->key

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.