Difference between revisions of "Development Best Practices"

From Joomla! Documentation

(Where should I place JavaScript files that belong to my Component?: Neaten up question to Joomla 1.6+ standards)
m (Removing split will be improved)
Line 1: Line 1:
{{page|needs improvement|It is severely outdated and needs a major revision.}}
{{page|needs improvement|It is severely outdated and needs a major revision.}}
{{split|Would this be better split into FAQ type page? Otherwise I suggest deletion.}}
== General Development Guidelines ==
== General Development Guidelines ==

Revision as of 03:47, 24 June 2014

This Article Needs Your Help

This article is tagged because it NEEDS IMPROVEMENT. You can help the Joomla! Documentation Wiki by contributing to it.
More pages that need help similar to this one are here. NOTE-If you feel the need is satistified, please remove this notice.

Reason: It is severely outdated and needs a major revision.

General Development Guidelines

  • Don't use the DS or DIRECTORY_SEPARATOR constant when including files. It is no longer needed, as pointed out by Christian on
  • Don't depend on register_globals. This is a HIGH security risk, and the feature has been deprecated in PHP 5.3 and removed in 5.4.

Where should I place JavaScript, CSS files that belong to my Component?

You can see in your root a general media folder to hold all assets.

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.