Unlimited number of blocks

IceCreamYou - August 28, 2008 - 03:51
Project:What Would Seth Godin Do?
Version:5.x-2.x-dev
Component:Miscellaneous
Category:feature request
Priority:normal
Assigned:Richard Eriksson
Status:active
Description

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.

#1

Richard Eriksson - September 5, 2008 - 23:56
Assigned to:Anonymous» Richard Eriksson

#2

Richard Eriksson - May 19, 2009 - 21:25
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.

#3

IceCreamYou - May 20, 2009 - 00:12

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

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

<?php
    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):

<?php
    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!

#4

Richard Eriksson - May 20, 2009 - 00:59

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.

 
 

Drupal is a registered trademark of Dries Buytaert.