confused squirrel

Joomla 3 Helper File Instructions

For my friends who don’t care about tech, just ignore this post.

If you are a Joomla developer, maybe you’ll find these notes helpful. I’m writing them down at the end of another week of circling through Joomla tutorials trying to get something to work the way I want. As is all too common, the instructions were contradictory and it seemed that every one left out some crucial piece of information. Hopefully I haven’t missed including any of the steps, because I’ve tried more variations than I can remember right now.

My goal: create a function that could be used anywhere in my component.

This was a true “helper” function and I needed it everywhere.

Here’s what I had to do to make it work:

  • start with a component com_mycomponent
  • in administrator/com_mycomponent/mycomponent.php add this line:
    JLoader::register(‘MycomponentHelpersMycomponent’, JPATH_COMPONENT . ‘/helpers/mycomponent.php’);
  • in administrator/com_mycomponent/helpers/ add mycomponent.php
  • in that file include these lines:
    abstract class MycomponentHelpersMycomponent
    {
          public static function mycustomfunction($params)
           { code your function here
            }
    }
  • when you want to use the function, just use this line:
    $result = MycomponentHelpersMycomponent::mycustomfunction($params);

Simple, right? Each bit of camel case is critical. You can use whatever $params you need (or none at all).

When I figure out how to make it work on the front end, too, I’ll update this post.

Maybe next time I can get this to work before 1AM.

Similar Posts

  • I’m MAD!

    I hate getting angry. My father had a temper. His face would turn red, and he would explode. Sadly, I seem to have inherited the potential to do just the same. So, I don’t do it often. I fight my anger, causing my blood pressure to alarm doctors. The stored up energy makes it ever…

  • Comment Connundrum

    My blog is broken. Or maybe it is just my blogging technique. You see what happens when I take a blogging class? I should be provoking at least some discussion on my blog. There’s a comment block down there. It has a captcha because I get an amazing amount of spam on this website. My…

  • Captivating

    (Typical disclaimer: includes religious commentary) My second summer trip was to Crooked Creek, Colorado, altitude: almost 10,000 feet above sea level. Anyone who spends much time with me quickly learns that I’m a sea-level kinda gal. My doctor was a dear and gave me some medication to make the transition easier, possibly because he was…

  • A Good Heart

    I heard about “the Good Heart” at the Ransomed Heart, Captivating retreat.  It took a few days for it to sink in. The premise is: what IF we could interact with others as if we knew they had a good heart–knew they meant nothing but the best for us? Of course, in an average day…

  • The Last Summer Trip

    If you’ve read this blog, you know I don’t believe in accidents. I had started out the summer with one trip planned: this one. I’d saved the money from my web design work for this one experience, and so it seems fitting that everything else built towards it. I went to a writer’s conference in…

Leave a Reply

Your email address will not be published. Required fields are marked *