Setting up a new Joomla Component Helper

Something that I don’t do often enough to remember how is setting up new a Joomla Component Helper in Joomla 3+.
I will be using my test component com_helpertest and the helper I’m adding this Joomla Component to is only for the administration area right now.

Creating your new helper class

Within the administrator/components/com_helpertest folder

  1. Create a folder helpers
  2. Create the php helper file in the folder, helpertest.php
    //minimal code for now
      abstract class HelpertestHelper {
          public static function test() {
              return 'test';
          }
      }
    
  3. In the administrator/components/com_helpertest/helpertest.php file add
    JLoader::import('helpers.helpertest',dirname(JPATH_COMPONENT_ADMINISTRATOR .DS.'helpers'.DS));
    
  4. Now should be able to use HelpertestHelper::test(); inside your component

    I have added this to my other Joomla notes here

Sponsor

About Chris Chase 17 Articles

Yeah i could write something here… but no that’s not going to happen.

Be the first to comment

Leave a Reply

Your email address will not be published.


*