Presentation "The Category Item Counter - developing a new feature" at Joomladay UK 2016 on February 13th in London, UK.
How does a new feature end up in Joomla? Peter talked about the new Category Item Counter feature that will be available in Joomla 3.5:
* the purpose of the feature
* where & how the idea for the "Nice" feature originated
* how the community helped to develop this feature
* how Joomla's development cycle works, including patch testing procedure, and who's Travis?
* the problems with differences in core components
* the hidden secret of com_categories
* how to add a Category Item Counter to your own component
Presentation video: http://www.youtube.com/watch?v=CK_tYC-Yy_c?t=45s
21. 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
22. 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
23. Use yourself
Category Manager: Your items
(via Components > Banners > your items) has the URL:
/administrator/index.php?
option=com_categories
&extension=com_yourcomponent
24. 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>
29. 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...
32. 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”
60. Add to helper
● Add to helper file
/administrator/components/com_your_
component/helpers/your_component.php
class YourcomponentHelper extends
JHelperContent
61. 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;
}
62. 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');
64. 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
65. 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