[development] development Digest, Vol 101, Issue 13

Darren Douglas Lee darrendouglas.lee at gmail.com
Thu May 12 18:51:54 UTC 2011


Steven,

Check out p. 177 of the Drupal 5 version of "Pro Drupal Development".
There's a little code snippit that might be of interest:

A select element example from statistics.module follows:
$period = drupal_map_assoc(array(3600, 10800, 21600, 32400, 43200, 86400,
172800,
259200, 604800, 1209600, 2419200, 4838400, 9676800), 'format_interval');
/* Period now looks like this:
Array (
[3600] => 1 hour
[10800] => 3 hours
[21600] => 6 hours
[32400] => 9 hours
[43200] => 12 hours
[86400] => 1 day
[172800] => 2 days
[259200] => 3 days
[604800] => 1 week
[1209600] => 2 weeks
[2419200] => 4 weeks
[4838400] => 8 weeks
[9676800] => 16 weeks )
*/
$form['access']['statistics_flush_accesslog_timer'] = array(
'#type' => 'select',
'#title' => t('Discard access logs older than'),
'#default_value' => variable_get('statistics_flush_accesslog_timer',
259200),
'#options' => $period,
'#description' => t('Older access log entries (including referrer
statistics)
will be automatically discarded. Requires crontab.')
);

On 12 May 2011 20:00, <development-request at drupal.org> wrote:

> Send development mailing list submissions to
>        development at drupal.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>        http://lists.drupal.org/mailman/listinfo/development
> or, via email, send a message with subject or body 'help' to
>        development-request at drupal.org
>
> You can reach the person managing the list at
>        development-owner at drupal.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of development digest..."
>
> Today's Topics:
>
>   1. Time interval inputs (Steven Jones)
>   2. Re: Time interval inputs (Hai-Nam aka jcisio)
>
>
> ---------- Forwarded message ----------
> From: Steven Jones <steven.jones at computerminds.co.uk>
> To: development <development at drupal.org>
> Date: Thu, 12 May 2011 07:32:02 +0100
> Subject: [development] Time interval inputs
> Hello developers,
>
> I maintain a number of modules that are related to doing something at
> a user defined interval, e.g. every 30 minutes or 12 hours etc. Most
> times I just use a single select box and pre-generate some options
> that I think users will want, but of course some users (myself
> included) want to be able choose an exact, but custom, interval.
>
> Is there any module out there that provides a generic 'interval' form
> element?
>
> I've looked at core, and it just uses some custom code each time to
> generate a list of intervals and pop them in a select list. I've also
> looked at other contrib modules and some of them just provide a
> textfield and others provide a textfield for numeric input and a
> select list for 'units'. There doesn't seem to be a catch-all solution
> that I can find, and everyone seems to implementing intervals in a
> slightly different way.
>
> Regards
> Steven Jones
> ComputerMinds ltd - Perfect Drupal Websites
>
> Phone : 024 7666 7277
> Mobile : 07702 131 576
> Twitter : darthsteven
> http://www.computerminds.co.uk
>
>
>
> ---------- Forwarded message ----------
> From: Hai-Nam aka jcisio <jcisio at gmail.com>
> To: development at drupal.org
> Date: Thu, 12 May 2011 09:45:54 +0200
> Subject: Re: [development] Time interval inputs
> Le 12/05/2011 08:32, Steven Jones a écrit :
> >
> > I've looked at core, and it just uses some custom code each time to
> > generate a list of intervals and pop them in a select list. I've also
> > looked at other contrib modules and some of them just provide a
> > textfield and others provide a textfield for numeric input and a
> > select list for 'units'. There doesn't seem to be a catch-all solution
> > that I can find, and everyone seems to implementing intervals in a
> > slightly different way.
> >
>
> In one of my module, I use a select list with prefined values to quickly
> fill a textfield with a choice. Then user can modify this textfield if
> they don't like any of these predefined values.
>
> Take a look at
> http://drupal.org/project/hidden_comment
>
> --
> Hai-Nam Nguyen aka jcisio
> http://jcisio.com
>
>
> --
> [ Drupal development list | http://lists.drupal.org/ ]
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20110513/8283827c/attachment.html 


More information about the development mailing list