The Category Item Counter
Developing a new feature for Joomla
by Peter Martin, @pe7er, www.db8.nl
Joomladay UK 2016, 13 February 2016
Origin of “nice”
new Feature
Developing new feature in Joomla - Joomladay UK 2016
Developing new feature in Joomla - Joomladay UK 2016
Developing new feature in Joomla - Joomladay UK 2016
Developing new feature in Joomla - Joomladay UK 2016
Developing new feature in Joomla - Joomladay UK 2016
Developing new feature in Joomla - Joomladay UK 2016
Developing new feature in Joomla - Joomladay UK 2016
Saturday 9 May 2015, around 15:00 / 16:00 hours (3-4pm)
Lesson 1
Share your ideas
for improvements constructively,
preferably in real life
(and not on Twitter)
“It's a pity that the
Joomla Category
Manager doesn't
have an Article
Counter anymore”
Marc Dechèvre
Developing new feature in Joomla - Joomladay UK 2016
“That should not
be that hard to
build in...”
Lesson 2
Have fun!
Developing new feature in Joomla - Joomladay UK 2016
Developing new feature in Joomla - Joomladay UK 2016
The hidden secret
of com_category
Joomla 1.5
● Articles + categories
● Banners + categories
● Contacts + categories
● Newsfeeds + categories
● Weblinks + categories
Counter:
extend SQL query with count statement
Joomla 3.x
● Articles
● Banners
● Contacts
● Newsfeeds
● Weblinks
● Categories → 1 dedicated component
Articles
● Article Manager: Articles
(via Content > Article Manager) has the URL:
/administrator/index.php?
option=com_content
&view=articles
● Category Manager: Articles
(Content > Category Manager) has the URL:
/administrator/index.php?
option=com_categories
&extension=com_content
Banners
● Banner Manager: Banners
(via Components > Banners > Banners) has the URL:
/administrator/index.php?
option=com_banners
● Category Manager: Banners
(via Components > Banners > Categories) has the URL:
/administrator/index.php?
option=com_categories
&extension=com_banners
Use yourself
Category Manager: Your items
(via Components > Banners > your items) has the URL:
/administrator/index.php?
option=com_categories
&extension=com_yourcomponent
Use yourself
Declare in JForm
administrator/components/com_yourcomponent/models/
forms/some_item.xml
<field
name="catid"
type="category"
extension="com_yourcomponent"
default=""
class="inputbox"
label="JCATEGORY"
description="JFIELD_CATEGORY_DESC"
required="true">
<option
value="0">JOPTION_SELECT_CATEGORY</option>
</field>
Lesson 3
Limit your project scope,
take small steps...
My scope
● com_content →
“if extension = com_content”
● Later on: make more generic...
Joomla's
development cycle
git
git
Distributed system
for Software Version Control
Github
Website with git repocitories
https://github.com/joomla/joomla-
cms/
git
● PR = Pull Request,
ask Joomla to pull the code from your private
fork into the Joomla project.
● Need two successful tests before RTC
= Ready To Commit
→code possibly in new version...
Lesson 4
Be willing to test
Patch tester
● Testing 123...
– Install Joomla staging + sample test data
– Install Patch Testing Component
– Load Pull Requests
– Read testing instruction,
test, install patch,
test, write report,
uninstall patch
git
● Patch for Bug?
→ next subversion (3.4.9)
● New Feature?
→ next main version (3.5)
gets labels: “milestone” + “New feature”
● New language strings?
gets label: “new language string”
My workflow
Create copy
/joomla/joomla-cms /pe7er/joomla-cms
Fork
Clone
Clone to PC
/joomla/joomla-cms
/pe7er/joomla-cms
Define “Upstream”Get all new changes
/joomla/joomla-cms
/pe7er/joomla-cms
New branch for new
code/feature
Push code to remote
Create Pull Request
Share new code
Lesson 5
Write clear test
instructions
Get tested
/joomla/joomla-cms
Pull request #no
Add clear testing instructions
Travis (automated)
2 x Human test
Lesson 6
Use screen dumps!
A picture = thousand words
Developing new feature in Joomla - Joomladay UK 2016
Developing new feature in Joomla - Joomladay UK 2016
“Hathor template?”
“Alignment
looks bad”
“can you try to
fix the Travis
errors?”
“Travis is not happy”
Photo: Pierre Sempé
Developing new feature in Joomla - Joomladay UK 2016
Developing new feature in Joomla - Joomladay UK 2016
Developing new feature in Joomla - Joomladay UK 2016
Developing new feature in Joomla - Joomladay UK 2016
Making it more
generic
Lesson 7
Ask for help
Articles
● Article Manager: Articles
(via Content > Article Manager) has the URL:
/administrator/index.php?
option=com_content
&view=articles
● Category Manager: Articles
(Content > Category Manager) has the URL:
/administrator/index.php?
option=com_categories
&extension=com_content
Loading submenu
option=com_categories
&extension=com_content
→ com_categories
gets helper file from
/administrator/components/com_content/
helpers/content.php
→ uses the method to create left submenu
Extend $query
administrator/components/
com_categories/models/categories.php
protected function getListQuery()
→ $query object will be extended by
$classname::countItems($query);
→ loads class from helper file other component
New tmpl
administrator/components/com_categories/views/
categories/tmpl/default.php - column header
<?php if (isset($this->items[0]) && property_exists($this-
>items[0], 'count_published')) :
$columns++; ?>
<th width="1%" class="nowrap center hidden-phone">
<i class="icon-publish"></i>
</th>
<?php endif;?>
New tmpl
administrator/components/com_categories/views/
categories/tmpl/default.php - clickable counter
<?php if (isset($this->items[0]) && property_exists($this->items[0],
'count_published')) : ?>
<td class="center btns hidden-phone">
<a class="badge <?php if ($item->count_published > 0) echo
"badge-success"; ?>" title="<?php echo Jtext::_('COM_
CATEGORY_COUNT_PUBLISHED_ITEMS');?>" href="<?php echo
JRoute::_('index.php?option=' . $component .
'&filter[category_id]=' . (int) $item->id . '&filter[published]=1' .
'&filter[level]=' . (int) $item->level);?>">
<?php echo $item->count_published; ?>
</a>
</td>
<?php endif;?>
More problems
in the core
Banners
● Status filter in all components:
&filter[published]
● Banners:
&filter[state]
Extending your
own component
Add to helper
● Add to helper file
/administrator/components/com_your_
component/helpers/your_component.php
class YourcomponentHelper extends
JHelperContent
New method
public static function countItems(&$query)
{
// Join articles to cats and count published items
$query->select('COUNT(DISTINCT cp.id) AS
count_published');
$query->join('LEFT', '#__yourcomponent_items
AS cp ON cp.catid = a.id AND cp.state = 1');
return $query;
}
Other counters
// Count unpublished items
$query->select('COUNT(DISTINCT cu.id) AS count_unpublished');
$query->join('LEFT', '#__yourcomponent_items AS cu ON cu.catid =
a.id AND cu.state = 0');
// Count archived items
$query->select('COUNT(DISTINCT ca.id) AS count_archived');
$query->join('LEFT', '#__yourcomponent_items AS ca ON ca.catid =
a.id AND ca.state = 2');
// Count trashed items
$query->select('COUNT(DISTINCT ct.id) AS count_trashed');
$query->join('LEFT', '#__yourcomponent_items AS ct ON ct.catid = a.id
AND ct.state = -2');
Conclusion
Summary
1.Share your ideas for improvements
constructively (not on Twitter)
2.Have fun!
3.Limit your scope, take small steps...
4.Be willing to test
5.Write clear test instructions
6.Use screen dumps
7.Ask for help
Thanks to everybody that helped developing
this new feature!
Peter Martin
e-mail: info at db8.nl
twitter: @pe7er
presentation available at: http://www.db8.nl
Contact

More Related Content

PDF
How to create a joomla component from scratch
PPTX
Introduction to building joomla! components using FOF
PPTX
Rapid application development using Akeeba FOF and Joomla 3.2
PDF
Developing a Joomla 3.x Component using RAD FOF- Part 2: Front-end + demo - J...
PPTX
Develop advance joomla! MVC Component for version 3
ODP
Problemen oplossen in Joomla - Joomladagen 2014
PPT
Rapid application development with FOF
PPT
Architecture of Drupal - Drupal Camp
How to create a joomla component from scratch
Introduction to building joomla! components using FOF
Rapid application development using Akeeba FOF and Joomla 3.2
Developing a Joomla 3.x Component using RAD FOF- Part 2: Front-end + demo - J...
Develop advance joomla! MVC Component for version 3
Problemen oplossen in Joomla - Joomladagen 2014
Rapid application development with FOF
Architecture of Drupal - Drupal Camp

What's hot (20)

PDF
Developing a Joomla 3.x Component using RAD FOF- Part 1: Back-end - Joomladay...
PPTX
State of play for Joomla - Nov 2014
PPTX
Joomla Tutorial: Joomla 2.5 a first look
PDF
Developing a Joomla 3.x Component using RAD/FOF - Joomladay UK 2014
PPTX
Develop Basic joomla! MVC component for version 3
PPTX
Extension developer secrets - How to make money with Joomla
PPTX
What’s new in joomla 3.7
PDF
Front End Development in Magento
ODP
Joomla 3 Component programmeren met RAD - Joomladagen 2014
PDF
Creating WordPress Theme Faster, Smarter & Without Swearing
PPTX
Drupal For Dummies
ODP
Joomla! Day UK 2009 Menus Presentation
PPTX
Magento 2 Theme Trainning for Beginners | Magenest
ODP
Joomla! Day UK 2009 Basic Templates
PDF
Joomla 15 Quickstart
PDF
那些年,我用 Django Admin 接的案子
ODP
Joomla Day UK 2009 Basic Templates
PDF
How To Create Theme in Magento 2 - Part 1
ODP
Bootstrap4 x pages
PPTX
Build a WordPress theme from HTML5 template @ Telerik
Developing a Joomla 3.x Component using RAD FOF- Part 1: Back-end - Joomladay...
State of play for Joomla - Nov 2014
Joomla Tutorial: Joomla 2.5 a first look
Developing a Joomla 3.x Component using RAD/FOF - Joomladay UK 2014
Develop Basic joomla! MVC component for version 3
Extension developer secrets - How to make money with Joomla
What’s new in joomla 3.7
Front End Development in Magento
Joomla 3 Component programmeren met RAD - Joomladagen 2014
Creating WordPress Theme Faster, Smarter & Without Swearing
Drupal For Dummies
Joomla! Day UK 2009 Menus Presentation
Magento 2 Theme Trainning for Beginners | Magenest
Joomla! Day UK 2009 Basic Templates
Joomla 15 Quickstart
那些年,我用 Django Admin 接的案子
Joomla Day UK 2009 Basic Templates
How To Create Theme in Magento 2 - Part 1
Bootstrap4 x pages
Build a WordPress theme from HTML5 template @ Telerik
Ad

Similar to Developing new feature in Joomla - Joomladay UK 2016 (20)

PDF
Extending CMS Made Simple
PPTX
Rapid application development using Akeeba FOF and Joomla 3.2
PPTX
How to Build a Website using Joomla
PDF
Techjoomla Infrastructure Extensions - Adding an Enterprise Layer to Joomla!
PDF
Joomla 101!
PDF
A complete guide to Joomla 2.5
PPT
Redlinesoft Joomla Basic Workshop
PDF
How to become a Joomla! Tester
PDF
Joomla! core features v1.2
PDF
Basics of Joomla!
KEY
JoomlaDay Barcelona 2009 talk about Joomla 1.6
PDF
Joomla 1.5 modules - Joomla!Days NL 2009 #jd09nl
ODP
Tips for Running a Large Website Using Joomla
PDF
Discovering Joomla! - Find out about Joomla's features
PPT
Joomla Day Austin Part 4
PDF
Joomla! v 1.5 Core Features
PPTX
Overview of CMS and Joomla!
DOC
DEEPAK RAWAT
PPTX
Improving joomla's backend user experience
PDF
Joomla Quick Start 1
Extending CMS Made Simple
Rapid application development using Akeeba FOF and Joomla 3.2
How to Build a Website using Joomla
Techjoomla Infrastructure Extensions - Adding an Enterprise Layer to Joomla!
Joomla 101!
A complete guide to Joomla 2.5
Redlinesoft Joomla Basic Workshop
How to become a Joomla! Tester
Joomla! core features v1.2
Basics of Joomla!
JoomlaDay Barcelona 2009 talk about Joomla 1.6
Joomla 1.5 modules - Joomla!Days NL 2009 #jd09nl
Tips for Running a Large Website Using Joomla
Discovering Joomla! - Find out about Joomla's features
Joomla Day Austin Part 4
Joomla! v 1.5 Core Features
Overview of CMS and Joomla!
DEEPAK RAWAT
Improving joomla's backend user experience
Joomla Quick Start 1
Ad

More from Peter Martin (20)

ODP
JCE editor optimaliseren (Joomla Den Bosc­h 2016)
ODP
Internet of Things - Linux Usergroup Nijmegen
PDF
Joomla: 10 years of progress (jd15fr)
ODP
Joomla 10-jaar-vooruitgang-jdnl15
ODP
Linux command-line-magic-jdnl15
PDF
GNU Radio & digitaal vliegtuig spotten
PDF
Help mijn website is gehackt - Joomla User Group Den Bosch 2014
PDF
Music Trackers - Linux Usergroup Nijmegen 2014
PDF
linux-commandline-magic-Joomla-World-Conference-2014
PDF
How IT works - Joomladay UK 2014
PDF
Joomla multilingual website without 3rd party extensions - Joomladay UK 2014
PDF
Troubleshooting Joomla! problems - Joomladay Germany 2014
PDF
How IT works - Joomladay Germany 2014
ODP
Linux Nijmegen - Webserver (LAMP stack) opzetten met VirtualbBox & Vagrant
ODP
Joomla Bugs, Patches & Fun - Joomladagen 2014
ODP
Basis Linux (aan de hand van LPIC-1)
ODP
JUG Utrecht 2013 - Optimaliseren van Joomla Content Editor (JCE) voor admins
ODP
JUG Utrecht 2013 - Have you tried turning it off and on again? Problemen oplo...
ODP
Joomla on Raspberry Pi using Nginx - Nederlandse Linux Gebruikers Group novem...
ODP
Configuring Joomla JCE editor from usability point of view
JCE editor optimaliseren (Joomla Den Bosc­h 2016)
Internet of Things - Linux Usergroup Nijmegen
Joomla: 10 years of progress (jd15fr)
Joomla 10-jaar-vooruitgang-jdnl15
Linux command-line-magic-jdnl15
GNU Radio & digitaal vliegtuig spotten
Help mijn website is gehackt - Joomla User Group Den Bosch 2014
Music Trackers - Linux Usergroup Nijmegen 2014
linux-commandline-magic-Joomla-World-Conference-2014
How IT works - Joomladay UK 2014
Joomla multilingual website without 3rd party extensions - Joomladay UK 2014
Troubleshooting Joomla! problems - Joomladay Germany 2014
How IT works - Joomladay Germany 2014
Linux Nijmegen - Webserver (LAMP stack) opzetten met VirtualbBox & Vagrant
Joomla Bugs, Patches & Fun - Joomladagen 2014
Basis Linux (aan de hand van LPIC-1)
JUG Utrecht 2013 - Optimaliseren van Joomla Content Editor (JCE) voor admins
JUG Utrecht 2013 - Have you tried turning it off and on again? Problemen oplo...
Joomla on Raspberry Pi using Nginx - Nederlandse Linux Gebruikers Group novem...
Configuring Joomla JCE editor from usability point of view

Recently uploaded (20)

PDF
CloudStack 4.21: First Look Webinar slides
PPTX
TEXTILE technology diploma scope and career opportunities
PPTX
GROUP4NURSINGINFORMATICSREPORT-2 PRESENTATION
PDF
“A New Era of 3D Sensing: Transforming Industries and Creating Opportunities,...
DOCX
search engine optimization ppt fir known well about this
PPTX
AI IN MARKETING- PRESENTED BY ANWAR KABIR 1st June 2025.pptx
PDF
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
PDF
Taming the Chaos: How to Turn Unstructured Data into Decisions
PDF
Produktkatalog für HOBO Datenlogger, Wetterstationen, Sensoren, Software und ...
PPTX
Configure Apache Mutual Authentication
PDF
sustainability-14-14877-v2.pddhzftheheeeee
PPTX
Final SEM Unit 1 for mit wpu at pune .pptx
PDF
How IoT Sensor Integration in 2025 is Transforming Industries Worldwide
PDF
Credit Without Borders: AI and Financial Inclusion in Bangladesh
PPT
Galois Field Theory of Risk: A Perspective, Protocol, and Mathematical Backgr...
PDF
STKI Israel Market Study 2025 version august
PDF
A proposed approach for plagiarism detection in Myanmar Unicode text
PPTX
Chapter 5: Probability Theory and Statistics
PPTX
Modernising the Digital Integration Hub
PPTX
Build Your First AI Agent with UiPath.pptx
CloudStack 4.21: First Look Webinar slides
TEXTILE technology diploma scope and career opportunities
GROUP4NURSINGINFORMATICSREPORT-2 PRESENTATION
“A New Era of 3D Sensing: Transforming Industries and Creating Opportunities,...
search engine optimization ppt fir known well about this
AI IN MARKETING- PRESENTED BY ANWAR KABIR 1st June 2025.pptx
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
Taming the Chaos: How to Turn Unstructured Data into Decisions
Produktkatalog für HOBO Datenlogger, Wetterstationen, Sensoren, Software und ...
Configure Apache Mutual Authentication
sustainability-14-14877-v2.pddhzftheheeeee
Final SEM Unit 1 for mit wpu at pune .pptx
How IoT Sensor Integration in 2025 is Transforming Industries Worldwide
Credit Without Borders: AI and Financial Inclusion in Bangladesh
Galois Field Theory of Risk: A Perspective, Protocol, and Mathematical Backgr...
STKI Israel Market Study 2025 version august
A proposed approach for plagiarism detection in Myanmar Unicode text
Chapter 5: Probability Theory and Statistics
Modernising the Digital Integration Hub
Build Your First AI Agent with UiPath.pptx

Developing new feature in Joomla - Joomladay UK 2016