Successfully reported this slideshow.

Developing new feature in Joomla - Joomladay UK 2016

1

Share

Loading in …3
×
1 of 65
1 of 65

Developing new feature in Joomla - Joomladay UK 2016

1

Share

Download to read offline

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

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

More Related Content

Related Books

Free with a 30 day trial from Scribd

See all

Related Audiobooks

Free with a 30 day trial from Scribd

See all

Developing new feature in Joomla - Joomladay UK 2016

  1. 1. The Category Item Counter Developing a new feature for Joomla by Peter Martin, @pe7er, www.db8.nl Joomladay UK 2016, 13 February 2016
  2. 2. Origin of “nice” new Feature
  3. 3. Saturday 9 May 2015, around 15:00 / 16:00 hours (3-4pm)
  4. 4. Lesson 1 Share your ideas for improvements constructively, preferably in real life (and not on Twitter)
  5. 5. “It's a pity that the Joomla Category Manager doesn't have an Article Counter anymore” Marc Dechèvre
  6. 6. “That should not be that hard to build in...”
  7. 7. Lesson 2 Have fun!
  8. 8. The hidden secret of com_category
  9. 9. Joomla 1.5 ● Articles + categories ● Banners + categories ● Contacts + categories ● Newsfeeds + categories ● Weblinks + categories Counter: extend SQL query with count statement
  10. 10. Joomla 3.x ● Articles ● Banners ● Contacts ● Newsfeeds ● Weblinks ● Categories → 1 dedicated component
  11. 11. 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
  12. 12. 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
  13. 13. Use yourself Category Manager: Your items (via Components > Banners > your items) has the URL: /administrator/index.php? option=com_categories &extension=com_yourcomponent
  14. 14. 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>
  15. 15. Lesson 3 Limit your project scope, take small steps...
  16. 16. My scope ● com_content → “if extension = com_content” ● Later on: make more generic...
  17. 17. Joomla's development cycle
  18. 18. git git Distributed system for Software Version Control Github Website with git repocitories https://github.com/joomla/joomla- cms/
  19. 19. 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...
  20. 20. Lesson 4 Be willing to test
  21. 21. 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
  22. 22. 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”
  23. 23. My workflow
  24. 24. Create copy /joomla/joomla-cms /pe7er/joomla-cms Fork Clone
  25. 25. Clone to PC /joomla/joomla-cms /pe7er/joomla-cms Define “Upstream”Get all new changes
  26. 26. /joomla/joomla-cms /pe7er/joomla-cms New branch for new code/feature Push code to remote Create Pull Request Share new code
  27. 27. Lesson 5 Write clear test instructions
  28. 28. Get tested /joomla/joomla-cms Pull request #no Add clear testing instructions Travis (automated) 2 x Human test
  29. 29. Lesson 6 Use screen dumps! A picture = thousand words
  30. 30. “Hathor template?”
  31. 31. “Alignment looks bad”
  32. 32. “can you try to fix the Travis errors?” “Travis is not happy”
  33. 33. Photo: Pierre Sempé
  34. 34. Making it more generic
  35. 35. Lesson 7 Ask for help
  36. 36. 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
  37. 37. 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
  38. 38. 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
  39. 39. 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;?>
  40. 40. 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;?>
  41. 41. More problems in the core
  42. 42. Banners ● Status filter in all components: &filter[published] ● Banners: &filter[state]
  43. 43. Extending your own component
  44. 44. Add to helper ● Add to helper file /administrator/components/com_your_ component/helpers/your_component.php class YourcomponentHelper extends JHelperContent
  45. 45. 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; }
  46. 46. 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');
  47. 47. Conclusion
  48. 48. 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
  49. 49. 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

×