To build applications with Enonic XP, you will typically setup a project. The fastest way to do this is using the init-project feature included in the Enonic XP toolbox utility.
The project structure is a similar to Maven projects for those who are familiar with that.
Below is a sample project folder structure - all items are folders, except for
my-first-app/ build.gradle src/ main/ java/ resources/ admin/ widgets/ tools/ assets/ lib/ services/ site/ content-types/ error/ filters/ i18n/ layouts/ mixins/ pages/ parts/ site.xml views/
Every file and folder has a specific function and meaning.
- Gradle script for building the application or library. This file describes the actual build process.
- Optional folder where you place any java code that might be included in the project - following traditional Maven style development.
- This is where all non-java code is placed, and thus where you will typically be working with your XP projects. All folders described below are relative to this folder
- This is where you place code for admin tools. Tools are administrative user interfaces (apps) running in their own separate browser tab. Create tools if you need a back-office utility to manage your applications or similar.
- Widgets are essentially user interface components that can be embedded within selected tools. I.e. you can create a widget that extends the Content Studio detail panel.
- This is the last place the global
site.xmlfile contains basic information for a site created with the application. Settings for the application can be defined in the
configelement and the values for these settings can be updated using the Content Studio tool.
<site> <x-data mixin="menu-item"/> <config> <field-set name="info"> <label>Info</label> <items> <input type="TextLine" name="company"> <label>Company</label> <occurrences minimum="1" maximum="1"/> </input> <input type="TextArea" name="description"> <label>Description</label> <occurrences minimum="1" maximum="1"/> </input> </items> </field-set> </config> </site>
- Content schemas are placed here. Used to create structured content (see Content Types).
- Create custom http error pages by placing an error controller in this directory (see Error Handling).
- This is where generic http response filters are placed. Filters can be used for post processing any given request - also across applications added to a site. A common use case is adding script tags to pages - but possibilities are virtually endless.
- This folder will contain application localization files (i18n is short for Internationalization). Files placed in this folder must follow Java’s standard property file format, one file for each language. Here is an example: https://docs.oracle.com/javase/tutorial/i18n/resbundle/propfile.html
- Mixin schema-types are placed here. A mixin can be used to add common fields to multiple content-types or other schemas (see Mixins).
- Page controllers are placed here. They will be used to render pages and page templates (see Page).
- Part controllers should be placed here. Parts are dynamically configurable components that can be placed on pages (see Part).
- Layout controllers should be placed here. Layouts are similar to parts, but in addition have one or more regions. Regions enable placement of other components inside the layout. (see Layout).
- Views are any kind of files that are used for rendering. The folder is optional, as view files can
- be placed anywhere you want, just keep in mind what path to use when resolving them (see Views).