I required fixed listing durations and couldn't figure out how to limit the date popup. So my first attempt at some code to provide me with 7,14,21 and 28 day listings seems to be a working solution.
In uc_aution.module I added the following around line 127
if (isset($form['#node']->uc_auction)) {
$expiry = /*format_date(*/intval($form['#node']->uc_auction['expiry'])/*, 'custom', 'r')*/;
}
else {
// 60s * 60m * 24h * 7d = 604800
$expiry = time() + 604800;
}
//added by PAOLO for Expiry Select List START
$expires1 = format_date($expiry, 'custom', 'Y-m-d H:i:s'); //total 7 days
$expires2 = format_date(($expiry + 604800), 'custom', 'Y-m-d H:i:s'); //total 14 days
$expires3 = format_date(($expiry + 1209600), 'custom', 'Y-m-d H:i:s'); //total 21 days
$expires4 = format_date(($expiry + 1814400), 'custom', 'Y-m-d H:i:s'); //total 28 days
//added by PAOLO for Expiry Select List END
$form['#validate'][] = 'uc_auction_form_validate';
And then further down where expiry is selected on the form (around line 160) I edited as follows...
'expiry' => array(
// MODIFIED BY PAOLO FOR EXPIRY DATE SELECT LIST
'#type' => 'select',
'#title' => t('Listing Duration'),
'#description' => t('Select how long you would like this listing to run for'),
'#required' => TRUE,
'#options' => array($expires1 => '7 Days',$expires2 => '14 Days',$expires3 => '21 Days',$expires4=>'28 Days'),
'#default_value' => $expires3,
'#weight' => 10,
),
);
This works perfectly for my needs, but turning this in to a feature or module is a little beyond my current experience with code and no doubt my code above could be tidied up by someone with the necessary skill and perhaps added to functionality in the module or a sub-module? I have attached a screenshot of the output on my site.
Hope this helps others with similar requirements.
Thanks
P.
| Comment | File | Size | Author |
|---|---|---|---|
| screenshotduration.jpg | 56.3 KB | smartparty |
Comments
Comment #1
neurosis commentedWhat would be required to turn this into:
Preset date length (7,14,21 Days) BUT User selected end Time (xx:xx) ??
Thanks