This module is greatly useful for a number of reasons, but I often find myself wishing I had more WWSGD blocks. I would love for a configurable number of blocks to be available.

The only real difficulty in making this possible is figuring out where to store the text value of each block. I think the best solution would be using a variable like variable_get('this_variable_'. $value, 0); where $value was the numeric value of the block that needed to be shown. I could probably help if necessary but I'm pretty limited with time right now.

Comments

sillygwailo’s picture

Assigned: Unassigned » sillygwailo
sillygwailo’s picture

Version: 5.x-1.x-dev » 5.x-2.x-dev

I'm making a 2.0 branch for this feature, still under development. Still work to be done on it, but the skeleton is in place if you check out DRUPAL-5--2 in CVS.

IceCreamYou’s picture

Cool. I like where this is going. I have a couple comments on the code:

In hook_block() under the 'save' op, this:

    db_query("UPDATE {wwsgd_blocks} SET max_visits = %d WHERE bid = %d", $edit['wwsgd_max_visits'], $delta);
    db_query("UPDATE {wwsgd_blocks} SET title = %s WHERE bid = %d", $edit['wwsgd_block_text'], $delta);

should be simplified to this (also you need single quotes around the %s or it's a security hole):

    db_query("UPDATE {wwsgd_blocks} SET max_visits = %d, title = '%s' WHERE bid = %d", $edit['wwsgd_max_visits'], $edit['wwsgd_block_text'], $delta);

In the submit handler for the "confirm delete" form, you should return the destination instead of using drupal_goto().

Instead of drupal_map_assoc(array(1,2,3,4,5,6,7,8,9,10)) I would use drupal_map_assoc(range(1, 10)).

Other than that, what you've got looks good. Looking forward to it!

sillygwailo’s picture

The design of the block admin function is a little strange (I know, I wrote it), so I'm going to hold off on that change. The other simplification changes are committed, though.

sillygwailo’s picture

Version: 5.x-2.x-dev » 6.x-2.x-dev
sillygwailo’s picture

In D7, hook_block_view_alter() or hook_block_info_alter() could conceivably let WWSGD modify any existing block's visibility depending on a counter.

mgifford’s picture

Version: 6.x-2.x-dev » 7.x-2.x-dev
Issue summary: View changes

Worth looking at how to do that. Would be quite interesting to be able to have a few welcoming blocks.