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
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 Dechvre
That should not be that hard to build in...
Lesson 2
Have fun!
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
JFormadministrator/components/com_yourcomponent/models/
forms/some_item.xml
JOPTION_SELECT_CATEGORY
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
Hathor template?
Alignment
looks bad
can you try to fix the Travis errors?
Travis is not happy
Photo: Pierre Semp
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
New tmpl
administrator/components/com_categories/views/
categories/tmpl/default.php - clickable counter
Top Related