Skip to content

Commit

Permalink
write new position field to mimic the one used in com_modules
Browse files Browse the repository at this point in the history
  • Loading branch information
lephuongbg committed Aug 25, 2013
1 parent 31b18fe commit 05da471
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 4 deletions.
37 changes: 37 additions & 0 deletions core/fields/position.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php
defined('JPATH_BASE') or die();

jimport('joomla.html.html');
jimport('joomla.form.formfield');

class JFormFieldPosition extends JFormField {
protected $type = "position";

protected function getInput() {
require_once JPATH_ADMINISTRATOR . '/components/com_modules/helpers/modules.php';
JHtml::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_modules/helpers/html');
$language = JFactory::getLanguage();
$language->load('com_modules', JPATH_ADMINISTRATOR);

$clientId = 0;
$state = 1;
$selectedPosition = $this->value;
$positions = JHtml::_('modules.positions', $clientId, $state, $selectedPosition);


// Add custom position to options
$customGroupText = JText::_('COM_MODULES_CUSTOM_POSITION');

// Build field
$attr = array(
'id' => $this->id,
'list.select' => $this->value,
'list.attr' => 'class="chzn-custom-value input-xlarge" '
. 'data-custom_group_text="' . $customGroupText . '" '
. 'data-no_results_text="' . JText::_('COM_MODULES_ADD_CUSTOM_POSITION') . '" '
. 'data-placeholder="' . JText::_('COM_MODULES_TYPE_OR_SELECT_POSITION') . '" '
);

return JHtml::_('select.groupedlist', $positions, $this->name, $attr);
}
}
8 changes: 4 additions & 4 deletions templateDetails.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
</field>
<field
name="logoPosition"
type="moduleposition"
type="position"
label="DZ_FIELD_LOGO_POSITION_LABEL"
description="DZ_FIELD_LOGO_POSITION_DESC"
/>
Expand Down Expand Up @@ -262,23 +262,23 @@
<field
name="responsive-767px-max"
label="DZ_FIELD_RESPONSIVE_767MAX_LABEL"
type="radio"
type="radio" class="btn-group"
default="1">
<option value="0">DZ_NO</option>
<option value="1">DZ_YES</option>
</field>
<field
name="responsive-768px-979px"
label="DZ_FIELD_RESPONSIVE_768-979_LABEL"
type="radio"
type="radio" class="btn-group"
default="1">
<option value="0">DZ_NO</option>
<option value="1">DZ_YES</option>
</field>
<field
name="responsive-1200px-min"
label="DZ_FIELD_RESPONSIVE_1200MIN_LABEL"
type="radio"
type="radio" class="btn-group"
default="1">
<option value="0">DZ_NO</option>
<option value="1">DZ_YES</option>
Expand Down

0 comments on commit 05da471

Please sign in to comment.