When submitting articles through the front end of Joomla they default to the uncategorised section, which is really annoying as users would likely forget to set the section and the article would then seem to dissapear.  What you can do is in your template index.php file add some javascript to set the default section to - Select a section - like this (making sure you have included <?php JHTML::_('behavior.mootools'); ?> to use the domready event):

window.addEvent('domready', function() {
var sectionid = document.getElementById('sectionid');
  var catid = document.getElementById('catid');
  if (location.href.match('submit-an-article') == 'submit-an-article' && sectionid != null && catid != null) {
   sectionid.selectedIndex = 0;
   catid.selectedIndex = -1;
   catid.options.length = 0;
  }
}

Then in components/com_content/views/articlew/tmpl/form.php add this above the catid check to ensure a section is selected:

} else if (form.sectionid && getSelectedValue('adminForm','sectionid') < 0){
  return alert ( "<?php echo JText::_( 'Please select a section', true ); ?>");

Another trick I've used to do with forms in Joomla is when using the mad4joomla mailforms extension edit the form_row function in the file components/com_mad4joomla/mad4joomla.html.php to add the help text as a style tag if it starts with style= to help with form design.

Comments are closed.