Development Best Practices
From Joomla! Documentation
Revision as of 09:02, 16 January 2011 by Mvangeest
Later on in the development of 1.5 we create a general media folder to all assets. At the moment this folder only holds the none-BC system assets. The idea was that the installer would push component specific assets in this folder during the installation process.
In JInstaller around line 780 we see the following in the parseMedia() method:
/* * Here we set the folder we are going to copy the files to. * Default 'media' Files are copied to the JPATH_BASE/images folder */ $folder = ($element->attributes('destination')) ? DS.$element->attributes('destination') : null; $destination = JPath::clean(JPATH_ROOT.DS.'media'.$folder);
What this means in real terms is that when in your xml install manifest, if you put files insite a <media> tag instead of a <files> tag then they will be sent to the JPATH_ROOT/media folder. If you give it <media destination="com_foo"> then it will put the files in JPATH_ROOT/media/com_foo
In some cases you have a component, we'll say com_foo, and then you have a few modules that go along with com_foo... for sake of the example we'll call them mod_foo_1, mod_foo_2 and mod_foo_3. There is no reason to package media elements for the three modules if they are all the same and they depend upon the component anyway. The best and most logical way to do things is to put them all in a central place that is namespaced appropriately.
Doing it this way gives us the ability to start taking all of the media assets out of our code folders and get us to a point where we could really move all the PHP files underneath the document root. It is a first step toward that end.
For the original discussion, see Joomla! Developer Discussion List.