Skip to content

Commit

Permalink
Adding an option to show/hide the time in the calendar field.
Browse files Browse the repository at this point in the history
Will use translated formats for all cases (form and item display)
  • Loading branch information
Thomas Hunziker committed Jan 23, 2017
1 parent 437a358 commit 10235c1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
4 changes: 2 additions & 2 deletions administrator/language/en-GB/en-GB.plg_fields_calendar.ini
Expand Up @@ -5,6 +5,6 @@

PLG_FIELDS_CALENDAR="Fields - Calendar"
PLG_FIELDS_CALENDAR_LABEL="Calendar"
PLG_FIELDS_CALENDAR_PARAMS_FORMAT_DESC="The date format to be used. This is in the format used by PHP to specify date string formats (see below). If no format argument is given, '%Y-%m-%d' is assumed (giving dates like '2008-04-16')."
PLG_FIELDS_CALENDAR_PARAMS_FORMAT_LABEL="Format"
PLG_FIELDS_CALENDAR_PARAMS_SHOWTIME_DESC="If enabled, the calendar field expects a date and time and will also display the time. The formats are localised using the regular language strings."
PLG_FIELDS_CALENDAR_PARAMS_SHOWTIME_LABEL="Show Time"
PLG_FIELDS_CALENDAR_XML_DESCRIPTION="This plugin lets create new fields of type 'Calendar' in the extensions where custom fields are implemented."
16 changes: 10 additions & 6 deletions plugins/fields/calendar/params/calendar.xml
Expand Up @@ -3,13 +3,17 @@
<fields name="fieldparams">
<fieldset name="fieldparams">
<field
name="format"
type="text"
class="input-xxlarge"
label="PLG_FIELDS_CALENDAR_PARAMS_FORMAT_LABEL"
description="PLG_FIELDS_CALENDAR_PARAMS_FORMAT_DESC"
name="showtime"
type="radio"
class="btn-group btn-group-yesno"
label="PLG_FIELDS_CALENDAR_PARAMS_SHOWTIME_LABEL"
description="PLG_FIELDS_CALENDAR_PARAMS_SHOWTIME_DESC"
size="20"
/>
default="0"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
</fieldset>
</fields>
</form>
4 changes: 3 additions & 1 deletion plugins/fields/calendar/tmpl/calendar.php
Expand Up @@ -21,4 +21,6 @@
$value = implode(', ', $value);
}

echo htmlentities(JHtml::_('date', $value, JText::_('DATE_FORMAT_LC4')));
$formatString = $field->fieldparams->get('showtime', 0) ? 'DATE_FORMAT_LC5' : 'DATE_FORMAT_LC4';

echo htmlentities(JHtml::_('date', $value, JText::_($formatString)));

0 comments on commit 10235c1

Please sign in to comment.