Fun with Joomla Forms

  • Last Updated: 07 August 2014

Thanks to Christophe Demko, Joomla supports the ability to dynamically add custom fields to the built-in contact form. This is accomplished via plugin using the onContentPrepareForm event. With this, we can create highly customized contact forms, and apply the same principles to other core forms on both the site and admin side of the site.

You can download the example form plugin used in this post at https://github.com/betweenbrain/Custom-Contact-Form-Plugin (ZIP file) and the plugin that adds custom field data to the core email at https://github.com/betweenbrain/Email-Additional-Fields (ZIP file)

Read more: Fun with Joomla Forms

Sticky Articles in Joomla 3

  • Last Updated: 19 March 2014

Making an article "sticky" in Joomla, as in it always appears at the top of the page, is fairly straight forward for the Featured Articles menu type as you can manually assign their ordering and give the sticky articles a negative value to force them to always be first.

But, what about regular Category Blog or Category List menus?

This is fairly simple and uses similar logic. In the case of most blogs, it makes sense to display the most recent article first. In our case, they will be displayed first after the sticky articles. To do this, change the menu item's Article Order setting to Most Recent First and change the Date for Ordering setting to Created. For the Category List menu type, these settings (as seen below) are in the List Layouts tab, and for the Category Blog menu type, are in the Blog Layout tab.

article-ordering-by-date

Once you have changed the menu items accordingly, you can then give your "sticky" articles a far future Created Date, found under the publishing tab of each article, and they will always be displayed before newly added articles.

Using this technique, you can even dynamically change the ordering of and even automate the publishing and unpublishing of sticky articles in Joomla by also using the Start and Finish Publising parameters.

future-created-date

PhpStorm Yuicompressor bug fix for Linux users

  • Last Updated: 17 February 2014

Linux users of PhpStorm may find that the Yuicompressor file watcher suddenly stop working with the recent release of PhpStorm version 7.1.1. The bug, present only for Linux users, is that the file watcher fails to recognize being the JAR file as being a valid program.

If you previously had the YUI Compressor CSS file watcher configured and working before upgrading, you may now get a message about not being able to execute the file, permission denied (error=13). If not, trying to confugre the watcher to use the JAR file accordingly to https://www.jetbrains.com/phpstorm/webhelp/minifying-css.html will not work as PhpStorm throws an error of

Please set error to run!

Fear not, all is not lost. The fix is simple in fact. Just point the file watcher to use $USER_HOME$/node_modules/yuicompressor/nodejs/cli.js instead of the JAR file.

Elena at Jetbrains was kind enough to confirm this is indead a bug (http://youtrack.jetbrains.com/issue/WEB-11037) and on track to be fixed.

Joomla World Conference 2013

  • Last Updated: 14 January 2014

Notes from Joomla! World Conference 2013, November 8-10, 2013, Boston, Massachusetts, USA

  1. The Joomla community is full of amazing people.
  2. Kevinjohn Gallagher is right. To paraphrase, the World Wide Web has lost its way of inclusiveness, and we are to blame for it. We can do better.
  3. Javier Gómez is probably the happiest guy on Earth, see for yourself (and I always have this strange urge to pinch his cheeks when I see him, not that I ever have).
  4. Issues should be called "oppurtunities for awesomness."
  5. I'm happy to see Joomla people hugging; we need more of that.
  6. We need to thank contributors more, communicate better, and not lick cookies. 
  7. GSoC is awesome, and great to see #JRockstars like Ram Tripathi join our community as a result of it.
  8. I'm inspired to create a multi-instance Vagrant application for Bug Squash events.
  9. Ethan Marcote could give a talk about dirt and I'd be inspired. His talk The Map and the Territory is an eye opening smack in the back of the head. He's also a helluva nice guy. Once again, we can do better.
  10. I am amazed about how many unrelated, unprompted conversations led to the same conclusion. Synchronicity?
  11. My daughter thinks that Tux is cute.
  12. My impression of a certain web hosting company hasn't changed, but changed substantially about another. Funny what substance does.
  13. Matt Mullenweg is very well spoken. My perception of WordPress has changed immensley. See for yourself.
  14. Kudos to Sander Potjer for building on the momentum of the event and immediately engaging with volunteers for the Joomla Volunteers Portal.
  15. Everyone can start using http://issues.joomla.org/ now. Please do so, and tweet "I'm beta testing the new #Joomla Issue Tracker at issues.Joomla.org and you should too! #jtracker"

Overriding K2 sub-templates in assigned site templates

  • Last Updated: 25 February 2013

K2 sub-templates extend the templating capabilities of Joomla! by allowing the creation of multiple, named sets of view overrides for K2 (the component) and certain K2 modules.

Any K2 component sub-template can be assigned to a K2 component category or K2 component menu item, and any K2 module sub-template is assignable to a module instances that support sub-templates (i.e. K2 Content module).

Read more: Overriding K2 sub-templates in assigned site templates

K2 Plugin Events

  • Last Updated: 25 January 2013

An un-official, and possibly incomplete, list of plugin events for K2 as of v2.6.2

Front-end:

  • Item
    • onK2PrepareContent(&$category, &$params, $limitstart)
    • onK2BeforeDisplay(&$item,&$params,$limitstart)
    • onK2AfterDisplay(&$item,&$params,$limitstart)
    • onK2AfterDisplayTitle(&$item,&$params,$limitstart)
    • onK2BeforeDisplayContent(&$item,&$params,$limitstart)
    • onK2AfterDisplayContent(&$item,&$params,$limitstart)
    • onK2PrepareContent(&$category, &$params, $limitstart)
    • onK2CategoryDisplay(&$category, &$params, $limitstart)
    • onK2PrepareContent(&$category, &$params, $limitstart)
  • Comments
    • onK2CommentsCounter(&$item, &$params, $limitstart)
    • onK2CommentsBlock(&$item, &$params, $limitstart)
  • Extra Fields
    • textarea / textfield
      • onContentPrepare('com_k2.'.$view,&$tmp,&$params,$limitstart) / onPrepareContent(&$tmp,&$params,$limitstart)
      • onK2PrepareContent(&$tmp,&$params,$limitstart)
  • Items
    • onK2BeforeSetQuery(&$query)
  • Category K2 plugins
    • onK2CategoryDisplay(&$category, &$params, $limitstart)
    • onK2PrepareContent(&$category, &$params, $limitstart)
  • User Plugins
    • onK2UserDisplay(&$item->author->profile, &$params, $limitstart)

Back-end:

  • Item
    • onBeforeK2Save(&$row,$isNew)
    • onAfterK2Save(&$row,$isNew)
    • onK2BeforeDownload(&$attachment,&$params)
    • onK2AfterDownload(&$attachment,&$params)
  • Items
    • onK2BeforeSetQuery(&$query)
    • onK2BeforeAssignFilters(&$filters)
    • onK2BeforeAssignColumns(&$columns)

DOCman 1.6.X DOClink Itemid issues

  • Last Updated: 04 December 2013

DOCman 1.6.x has an interesting behavior of using the Itemid of the first DOCman menu item it finds in the menu tree, not necessarily that of the page you are editing, when manually inserting a link in a Joomla article.

For example, if you have a DOCman category layout with an Itemid of 111, and have also created a single article menu item, with the Itemid of 115, DOCman's DOClinks will not use Itemid=115 when inserting a link into the single article. It will, instead, use Itmid=111 as that is the first DOCman item it finds.

The fix is to first insert the DOCman link as you would normally, then manuall change the Itemid parameter of the URL. In the above example, DOClink inserted

index.php?option=com_docman&task=doc_download&gid=591&Itemid=111
so I changed it to
index.php?option=com_docman&task=doc_download&gid=591&Itemid=115

On Achieving Responsiveness

  • Last Updated: 04 December 2013

An abbreviation of Wikipedia's definition of Responsive Web Design (RWD) is that it is an approach [where] a site is crafted to provide an optimal viewing experience across a wide range of devices

While I agree with this definition, it needs to be further refined as also creating a cohesive user experience among all devices. If a user were to sit down with a number of different devices (let's say a smart phone, tablet, and notebook computer) that user should be able to transition from one device to another without any sort of learning curve or need to become re-aquanted with the site. This is not to say that the design on each device would look the same, but the user experience would be similar and equally intuitive.

Read more: On Achieving Responsiveness

Media Queries Are About Content, Not Screen Size

  • Last Updated: 25 September 2012

In an act consisting of equal parts of pure @beep groupie-ism and Responsive Web Design fanaticism, I closed up shop early today and drove the six hour round trip to Boston and back (not to mention consuming copious amounts of coffee and fast food terror) so that I could be present at Real World Applications of Responsive Web Design featuring Ethan Marcotte, Mat Marquis, and Miranda Mulligan.

To sum up the event, it was awesome. Awesome in the sense that it inspired awe, and an "ah ha!" moment. That moment occurred when it became clear on how media queries should be used in a device agnostic application. In other words, approaching EM based media queries that are focused on content.

In his talk, Ethan described the atomic unit of measure for a site's media queries to be based on "the ideal line length of a single column of text." That atomic unit of measure is the basis for further media queries, or breakpoints. For example, the font type and size, and even line height used in a site's design may lend to the optimal line length of a single column of text (i.e. the tiny screen version) to be 20em. With this being the case, other natural increments may occur at 30em, 45em, and even 60em. Determining these increments are as much art, science, and feel (start resizing your borwsers like crazy). In any case, they have nothing to do with screen size and device resolution, and never will.

Joomla, Say Goodbye to Conditional Comments

  • Last Updated: 04 December 2013

A simple and effective way to handle to the various quirks between the different versions of Internet Explorer is the use of conditional comments to load specific stylesheets, declarations, or even classes. For example, HTML5 Boilerplate addresses this by implementing Paul Irish's Conditional stylesheets vs CSS hacks? Answer: Neither!:

<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en"> <![endif]-->
<!--[if IE 7]>    <html class="no-js ie7 oldie" lang="en"> <![endif]-->
<!--[if IE 8]>    <html class="no-js ie8 oldie" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->

However, conditional comments add extra code to your document and are limited to only Internet Explorer.

Joomla to the rescue!

Since Joomla! 1.5, JBrowser has existed to help us identity the client's browser by examining the HTTP_USER_AGENT. By leveraging JBrowser, we can not only eliminate the use conditional statements in templates, but also expand browser specific rules beyond IE and do this server-side.

Read more: Joomla, Say Goodbye to Conditional Comments