Installation of required custom classes

Have a programming question regarding your component, plug-in, extension or core hacks? Have an interesting tidbit, FAQ or programming tip you’d like to share? This is the place for you.

Moderators: tjay, seadap, Rogue4ngel, matthewhayashida

Post Reply
bass28
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Mon Apr 17, 2006 5:11 pm

Installation of required custom classes

Post by bass28 » Fri Aug 24, 2007 8:32 pm

The component I am developing has several custom classes that are required by both the frontend and adminstration area.  Is it recommended to copy the classes to both components/mycomponent and administrator/components/mycomonents or should I reference one from the other?

kdevine
Joomla! Apprentice
Joomla! Apprentice
Posts: 18
Joined: Thu Mar 02, 2006 8:38 pm
Location: Baltimore, MD

Re: Installation of required custom classes

Post by kdevine » Fri Aug 24, 2007 9:52 pm

If your custom component requires it's own library I would recommend storing the library in only one location. Either in the frontend or in the administrator is up to you but I would recommend storing your library in administrator -> components -> com_yourcomponent -> libraries

You would then import your library in the entry point file of your component.

If the libraries are in the frontend you can use the constant JPATH_COMPONENT_SITE.
If the libraries are in the backend you can use the constant JPATH_COMPONENT_ADMINISTRATOR.

The contsant, JPATH_COMPONENT, will give the component directory the file is currently in. So, for example if calling the constant from the frontend entry point file the path will be for the frontend of the component but if calling that constant from the entry point file of your component in the administrator backend the path will be for the backend component directory. In use it would be this...

Code: Select all

require_once(JPATH_COMPONENT.DS.'libraries'.DS.'customlibraryfile.php');


Substitute either JPATH_COMPONENT_SITE or JPATH_COMPONENT_ADMINISTRTOR for JPATH_COMPONENT if you would like.

I hope that was clear but if not, let me know.


Post Reply