Skip to content

Commit

Permalink
branches now retrieved via fields
Browse files Browse the repository at this point in the history
  • Loading branch information
pe7er committed Nov 4, 2015
1 parent 1a321f0 commit 069aa85
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 4 deletions.
52 changes: 52 additions & 0 deletions administrator/components/com_finder/models/fields/branches.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_finder
*
* @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/

defined('JPATH_BASE') or die();

JFormHelper::loadFieldClass('list');

/**
* Search Filter field for the Finder package.
*
* @since 3.5
*/
class JFormFieldBranches extends JFormFieldList
{
/**
* The form field type.
*
* @var string
* @since 3.5
*/
protected $type = 'Branches';

/**
* Method to get the field options.
*
* @return array The field option objects.
*
* @since 3.5
*/
public function getOptions()
{
// Build the query.
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('id AS value, title AS text')
->from($db->quoteName('#__finder_taxonomy'))
->where('parent_id = 1')
->order('title ASC');
$db->setQuery($query);
$options = $db->loadObjectList();

array_unshift($options, JHtml::_('select.option', '', JText::_('COM_FINDER_MAPS_SELECT_BRANCHE'), 'value', 'text'));

return $options;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset addfieldpath="/administrator/components/com_templates/models/fields" />

<fields name="filter">
<field
name="search"
Expand All @@ -17,17 +19,16 @@
>
<option value="">JOPTION_SELECT_PUBLISHED</option>
</field>

<field
name="branch"
type="sql"
type="branches"
default="0"
query="SELECT id AS value, title AS branch FROM #__finder_taxonomy WHERE parent_id = 1"
label="JOPTION_FILTER_CATEGORY"
description="JOPTION_FILTER_CATEGORY_DESC"
onchange="this.form.submit();"
>
<option value="">COM_FINDER_MAPS_SELECT_BRANCHE</option>
</field>

</fields>
<fields name="list">
<field
Expand Down

0 comments on commit 069aa85

Please sign in to comment.