diff --git a/src/components/com_weblinks/models/category.php b/src/components/com_weblinks/models/category.php
index d145e8c..b7658cc 100644
--- a/src/components/com_weblinks/models/category.php
+++ b/src/components/com_weblinks/models/category.php
@@ -121,9 +121,20 @@ class WeblinksModelCategory extends JModelList
// Filter by category.
if ($categoryId = $this->getState('category.id'))
{
- $query->where('a.catid = ' . (int) $categoryId)
- ->join('LEFT', '#__categories AS c ON c.id = a.catid')
- ->where('c.access IN (' . $groups . ')');
+ // Group by subcategory
+ if($this->getState('category.group', 0))
+ {
+ $query->select('c.title AS category_title')
+ ->where('c.parent_id = ' . (int) $categoryId)
+ ->join('LEFT', '#__categories AS c ON c.id = a.catid')
+ ->where('c.access IN (' . $groups . ')');
+ }
+ else
+ {
+ $query->where('a.catid = ' . (int) $categoryId)
+ ->join('LEFT', '#__categories AS c ON c.id = a.catid')
+ ->where('c.access IN (' . $groups . ')');
+ }
// Filter by published category
$cpublished = $this->getState('filter.c.published');
@@ -176,6 +187,16 @@ class WeblinksModelCategory extends JModelList
$search = $db->quote('%' . $db->escape($search, true) . '%');
$query->where('(a.title LIKE ' . $search . ')');
}
+
+ // If grouping by subcategory, add the subcategory list ordering clause.
+ if($this->getState('category.group', 0))
+ {
+ $query->order(
+ $db->escape(
+ $this->getState('category.ordering', 'c.lft')) . ' ' . $db->escape($this->getState('category.direction', 'ASC')
+ )
+ );
+ }
// Add the list ordering clause.
$query->order(
diff --git a/src/language/en-GB/en-GB.mod_weblinks.ini b/src/language/en-GB/en-GB.mod_weblinks.ini
index 6e5588a..604433d 100644
--- a/src/language/en-GB/en-GB.mod_weblinks.ini
+++ b/src/language/en-GB/en-GB.mod_weblinks.ini
@@ -5,6 +5,16 @@
MOD_WEBLINKS="Web Links"
MOD_WEBLINKS_FIELD_CATEGORY_DESC="Choose the Web Links category to display."
+MOD_WEBLINKS_FIELD_GROUPBY_DESC="If set to yes, weblinks will be grouped by subcategories."
+MOD_WEBLINKS_FIELD_GROUPBY_LABEL="Group By Subcategories"
+MOD_WEBLINKS_FIELD_GROUPBYSHOWTITLE_DESC="If set to yes, will show groups titles (valid only if grouping)."
+MOD_WEBLINKS_FIELD_GROUPBYSHOWTITLE_LABEL="Show Group Title"
+MOD_WEBLINKS_FIELD_GROUPBYORDERING_DESC="Ordering for the subcategories (valid only if grouping)."
+MOD_WEBLINKS_FIELD_GROUPBYORDERING_LABEL="Group Ordering"
+MOD_WEBLINKS_FIELD_GROUPBYDIRECTION_DESC="Direction for the subcategories (valid only if grouping)."
+MOD_WEBLINKS_FIELD_GROUPBYDIRECTION_LABEL="Group Ordering Direction"
+MOD_WEBLINKS_FIELD_COLUMNS_DESC="When grouping by subcategories, split into # columns."
+MOD_WEBLINKS_FIELD_COLUMNS_LABEL="Columns"
MOD_WEBLINKS_FIELD_COUNT_DESC="Number of Web Links to display."
MOD_WEBLINKS_FIELD_COUNT_LABEL="Count"
MOD_WEBLINKS_FIELD_COUNTCLICKS_DESC="If set to yes, the number of times the link has been clicked will be recorded."
diff --git a/src/modules/mod_weblinks/helper.php b/src/modules/mod_weblinks/helper.php
index 11c031b..7dee5dd 100644
--- a/src/modules/mod_weblinks/helper.php
+++ b/src/modules/mod_weblinks/helper.php
@@ -57,6 +57,9 @@ class ModWeblinksHelper
$catid = (int) $params->get('catid', 0);
$model->setState('category.id', $catid);
+ $model->setState('category.group', $params->get('groupby', 0));
+ $model->setState('category.ordering', $params->get('groupby_ordering', 'c.lft'));
+ $model->setState('category.direction', $params->get('groupby_direction', 'ASC'));
// Create query object
$db = JFactory::getDbo();
diff --git a/src/modules/mod_weblinks/mod_weblinks.xml b/src/modules/mod_weblinks/mod_weblinks.xml
index 1fa8a84..644f488 100644
--- a/src/modules/mod_weblinks/mod_weblinks.xml
+++ b/src/modules/mod_weblinks/mod_weblinks.xml
@@ -20,141 +20,204 @@
diff --git a/src/modules/mod_weblinks/tmpl/default.php b/src/modules/mod_weblinks/tmpl/default.php
index 52c7ad5..3342cb0 100644
--- a/src/modules/mod_weblinks/tmpl/default.php
+++ b/src/modules/mod_weblinks/tmpl/default.php
@@ -9,47 +9,120 @@
defined('_JEXEC') or die;
?>
-
-
-
- link;
+get('groupby', 0)) :
- switch ($params->get('target', 3))
- {
- case 1:
- // Open in a new window
- echo '' .
- htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '';
- break;
+ $cats = array();
+ $cols = $params->get('groupby_columns', 3);
- case 2:
- // Open in a popup window
- echo "" .
- htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '';
- break;
+ foreach ($list as $l)
+ $cats[] = array('catid' => $l->catid, 'title' => $l->category_title);
- default:
- // Open in parent window
- echo '' .
- htmlspecialchars($item->title, ENT_COMPAT, 'UTF-8') . '';
- break;
- }
+ $cats = array_values(array_map('unserialize', array_unique(array_map('serialize', $cats))));
- if ($params->get('description', 0))
- {
- echo nl2br($item->description);
- }
+ foreach ($cats as $k => $cat) :
- if ($params->get('hits', 0))
- {
- echo '(' . $item->hits . ' ' . JText::_('MOD_WEBLINKS_HITS') . ')';
- }
- ?>
-