

My template also has a css.map file in the same css directory. I only want "css" files to show here, so I'm filtering for files with "css" in them. The fileFilter is a regex expression to filter files. The description comes from the language file, and is displayed under the selection. If it's called something other than "verysimple" you will need to insert your own template alias here. Remember to use the media directory for YOUR template. It's relative to the Joomla site root directory. The directory is where it will source the files from. The label again comes from the language file. The name I gave it is "style." It's of type filelist. This way, template users have more options to customize their template if they don't like the default colors. My plan is to create multiple stylesheets with slight variations in colors. The last field I want to create allows the user to select from any CSS file in the template's media folder. That's all I need to create a text field.

I set the field name to "slogan" it's of type "text" and the label comes from the language file. Filters can be applied to these text fields if needed, read the official Joomla docs for more information on that. They just allow users to enter a string of text. Text fields are a little simpler than radio fields. TPL_VERYSIMPLE_STYLE_DESC="The stylesheet to load with this template" The Text Field (Slogan) I have modified my tpl_verysimple.ini language file to contain the following: TPL_VERYSIMPLE_CONTAINERLAYOUT="Container Width" The general recommendation is to use the language files for all text being displayed. But your template won't be as easily translatable if someone wants to modify it to work in other languages. You could just type the fields and their options in plain text here, if you want. Specifically, for my template, it's coming from site_root/language/en-GB/tpl_verysimple.ini The text in caps comes from the language files. We will read these values later in the template using PHP and make a decision based upon it. The values in this case will be either 0 if the user wants a fixed layout and 1 if the user wants a fluid layout. The name should be a short name used internally with no spaces.

For radio buttons, define the name, what type of field it is (radio), the field's label shown to the user, the default value, the layout, a filter, and the options. You must define several pieces of information to create a field. Here, it's going to be a radio field with the label saying "Container Width" and options of either "Fluid" or "Fixed" To define the container layout as being fixed or fluid, I'm going to use a radio field.

Joomla 4 template full#
For this guide, I'm going to be using a boolean/radio field for fluid/fixed with, a text field for the slogan, and a filelist field for the css option.įor a full list of fields and their options, you can see the official Joomla docs on standard field types. There are many field types to choose from. templateDetails.xml Įach field is defined in a element. If you already have a config section, either delete the fields or only keep the ones you plan on using.
Joomla 4 template code#
If you've made a template from scratch, you can easily add a config section.Īdd the following code to your templateDetails.xml file, at the end, but before the last tag. If you started with my j4starter template, there should already be one example field here. Towards the bottom of the XML document, there's a section. To define fields in the options of a template, you must modify the templateDetails.xml file in your template's folder.
