Skip to content

Commit

Permalink
Merge pull request #88 from Didldu-Florian/dev
Browse files Browse the repository at this point in the history
categories view - count items feature
  • Loading branch information
HRIT-Florian authored Feb 15, 2018
2 parents 3145a87 + 7fdc2fe commit 4c5b760
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 3 deletions.
2 changes: 2 additions & 0 deletions admin/language/de-DE/de-DE.com_dd_gmaps_locations.ini
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ COM_DD_GMAPS_LOCATIONS_LOCATIONS_ORDER_DESC="Die Reihenfolge, in der die Standor
COM_DD_GMAPS_LOCATIONS_LOCATIONS_ORDER="Standard"
COM_DD_GMAPS_LOCATIONS_LOCATIONS_ORDER_TITLE_ALPHABETICAL="Alphabetisch"
COM_DD_GMAPS_LOCATIONS_LOCATIONS_ORDER_TITLE_REVERSE_ALPHABETICAL="Alphabetisch absteigend"
COM_DD_GMAPS_LOCATIONS_LOCATIONS_COUNT_ITEMS_LABEL="Einträge aufzählen"
COM_DD_GMAPS_LOCATIONS_LOCATIONS_COUNT_ITEMS_DESC="Zeigt die Anzahl der Standorte in Kategorien an."

COM_DD_GMAPS_LOCATIONS_LOCATIONS_SETTINGS_FILTER_CATEGORYLIST_LABEL="Kategorie Optionen"
COM_DD_GMAPS_LOCATIONS_LOCATIONS_FILTER_SHOW_CATID_DESC_LABEL="Zeige Kategorie Beschreibung"
Expand Down
2 changes: 2 additions & 0 deletions admin/language/en-GB/en-GB.com_dd_gmaps_locations.ini
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ COM_DD_GMAPS_LOCATIONS_LOCATIONS_ORDER_DESC="The order in which the locations ar
COM_DD_GMAPS_LOCATIONS_LOCATIONS_ORDER="Default"
COM_DD_GMAPS_LOCATIONS_LOCATIONS_ORDER_TITLE_ALPHABETICAL="Alphabetical"
COM_DD_GMAPS_LOCATIONS_LOCATIONS_ORDER_TITLE_REVERSE_ALPHABETICAL="Reverse alphabetical"
COM_DD_GMAPS_LOCATIONS_LOCATIONS_COUNT_ITEMS_LABEL="Count items"
COM_DD_GMAPS_LOCATIONS_LOCATIONS_COUNT_ITEMS_DESC="Shows the number of locations in categories."

COM_DD_GMAPS_LOCATIONS_LOCATIONS_SETTINGS_FILTER_CATEGORYLIST_LABEL="Category Options"
COM_DD_GMAPS_LOCATIONS_LOCATIONS_FILTER_SHOW_CATID_DESC_LABEL="Show category desc"
Expand Down
13 changes: 11 additions & 2 deletions admin/language/ru-RU/ru-RU.com_dd_gmaps_locations.ini
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ COM_DD_GMAPS_LOCATIONS_HEADING_COUNTRY="Страна"
COM_DD_GMAPS_LOCATIONS_HEADING_MARKER_TITEL="Категория маркер"
COM_DD_GMAPS_LOCATIONS_HEADING_MARKER_IMAGE="Маркер изображения категории"

; todo translate
COM_DD_GMAPS_LOCATIONS_MARKER_NOTICE="Markers are defined by individual categories. Category Image under Options. Recommended size max. 55px by 55px."

COM_DD_GMAPS_LOCATIONS_FIELD_TITLE_DESC="Заголовок для локального входа."
COM_DD_GMAPS_LOCATIONS_FIELD_ALIAS_DESC="Aлиас генерирует из ID и заголовка для профиля URL, заполняется после сохранения."
COM_DD_GMAPS_LOCATIONS_FIELD_CATID_LABEL="Категория"
Expand Down Expand Up @@ -102,6 +105,12 @@ COM_DD_GMAPS_LOCATIONS_FIELD_LATITUDE_DESC="Координаты (градус
COM_DD_GMAPS_LOCATIONS_FIELD_LONGITUDE_LABEL="Градус долготы"
COM_DD_GMAPS_LOCATIONS_FIELD_LONGITUDE_DESC="Координаты (градус долготы) для API геокодирования Google заполнен после сохранения. Координаты не смогут быть изменены."

; todo translate
COM_DD_GMAPS_LOCATIONS_FIELD_LATITUDE_LABEL="Latitude"
COM_DD_GMAPS_LOCATIONS_FIELD_LATITUDE_DESC="The coordinates (latitude) from geocoding Google API, filled after saving. Coordinates can not be edited."
COM_DD_GMAPS_LOCATIONS_FIELD_LONGITUDE_LABEL="Longitude"
COM_DD_GMAPS_LOCATIONS_FIELD_LONGITUDE_DESC="The coordinates (longitude) from geocoding Google API, filled after saving. Coordinates can not be edited."

COM_DD_GMAPS_LOCATIONS_FIELD_LATITUDE_LONGITUDE_CUSTOM_ENABLE_LABEL="Геокодирование жесткое кодирование: (Экспериментально)"
COM_DD_GMAPS_LOCATIONS_FIELD_LATITUDE_LONGITUDE_CUSTOM_ENABLE_DESC="Этот параметр переписывает из адреса автоматически генерированы данные географического положения!"
COM_DD_GMAPS_LOCATIONS_FIELD_LATITUDE_CUSTOM_LABEL="Настроить самостоятельно градус широты "
Expand Down Expand Up @@ -153,16 +162,16 @@ COM_DD_GMAPS_LOCATIONS_COMPONENT_COUNTRIES_SELECTION_EXTENDED="<span class='red'
COM_DD_GMAPS_LOCATIONS_LOCATIONS_SETTINGS_LABEL="Настройки географического положения"
COM_DD_GMAPS_LOCATIONS_LOCATIONS_ITEMS_TO_LIST_LABEL="Количество по умолчанию на список"
COM_DD_GMAPS_LOCATIONS_LOCATIONS_ITEMS_TO_LIST_DESC="Количество по умолчанию перечисленных элементов на странице"

COM_DD_GMAPS_LOCATIONS_LOCATIONS_ITEMS_MORE_LABEL="Дальнейшшее количество."
COM_DD_GMAPS_LOCATIONS_LOCATIONS_ITEMS_MORE_DESC="Количество дальнейших перечисленных географических положений на следующей странице."

; todo translate
COM_DD_GMAPS_LOCATIONS_LOCATIONS_ORDER_LABEL="List Options"
COM_DD_GMAPS_LOCATIONS_LOCATIONS_ORDER_DESC="The list options in which the locations are displayed."
COM_DD_GMAPS_LOCATIONS_LOCATIONS_ORDER="Default"
COM_DD_GMAPS_LOCATIONS_LOCATIONS_ORDER_TITLE_ALPHABETICAL="Alphabetical"
COM_DD_GMAPS_LOCATIONS_LOCATIONS_ORDER_TITLE_REVERSE_ALPHABETICAL="Reverse alphabetical"
COM_DD_GMAPS_LOCATIONS_LOCATIONS_COUNT_ITEMS_LABEL="Count items"
COM_DD_GMAPS_LOCATIONS_LOCATIONS_COUNT_ITEMS_DESC="Shows the number of locations in categories."

COM_DD_GMAPS_LOCATIONS_LOCATIONS_SETTINGS_FILTER_CATEGORYLIST_LABEL="Category Options"
COM_DD_GMAPS_LOCATIONS_LOCATIONS_FILTER_SHOW_CATID_DESC_LABEL="Show Category desc"
Expand Down
18 changes: 18 additions & 0 deletions site/models/categories.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,22 @@ protected function populateState($ordering = null, $direction = null, $listlimit
{
parent::populateState($ordering, $direction);

$app = JFactory::getApplication();
$params = $app->getParams();

$catid = (int) JFactory::getApplication()->input->get('catid');

// Category
if ($catid)
{
$this->setState('dd_filter.catid', $catid);
}

// Count locations
if ($params->get('count_items', false))
{
$this->setState('dd_filter.count_items', $params->get('count_items'));
}
}

/**
Expand All @@ -59,6 +68,15 @@ public function getListQuery()
->where($db->qn('cc.id') . ' = ' . $db->q($catid))
->where($db->qn('c.published') . '= 1 OR' . ($db->qn('c.id') . ' = ' . $db->q($catid)));

// Count items
if ($this->getState('dd_filter.count_items'))
{
$query->select('COUNT(*) AS ' . $db->qn('count'))
->join('LEFT', $db->qn('#__dd_gmaps_locations', 'a') . ' ON ' . $db->qn('a.catid') . ' = ' . $db->qn('c.id'))
->where($db->qn('a.state') . '= 1')
->group($db->qn('c.id'));
}

$db->setQuery($query);

return $query;
Expand Down
6 changes: 5 additions & 1 deletion site/views/categories/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
<?php foreach ($this->items as $i => $item): ?>
<?php if ($i % 3 == 0){ echo '</div><div class="row-fluid">'; } ?>
<div class="span4 category well">
<h5><?php echo $this->escape($item->title); ?></h5>
<h5 class="pull-left"><?php echo $this->escape($item->title); ?></h5>
<?php if($this->params->get('count_items')):?>
<span class="badge pull-right"><?php echo $item->count; ?></span>
<hr class="clear">
<?php endif; ?>
<img src="<?php echo json_decode($item->params)->image; ?>" alt="<?php echo json_decode($item->params)->image_alt; ?>">
<hr>
<div class="category-desc">
Expand Down
21 changes: 21 additions & 0 deletions site/views/categories/tmpl/default.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,25 @@

</fieldset>
</fields>

<!-- Add fields to the parameters object for the layout. -->
<fields name="params">

<!-- Basic options. -->
<fieldset name="basic"
label="COM_DD_GMAPS_LOCATIONS_LOCATIONS_SETTINGS_LABEL">

<field
name="count_items"
type="radio"
class="btn-group btn-group-yesno"
default="0"
label="COM_DD_GMAPS_LOCATIONS_LOCATIONS_COUNT_ITEMS_LABEL"
description="COM_DD_GMAPS_LOCATIONS_LOCATIONS_COUNT_ITEMS_DESC"
>
<option value="1">JSHOW</option>
<option value="0">JHIDE</option>
</field>
</fieldset>
</fields>
</metadata>

0 comments on commit 4c5b760

Please sign in to comment.