Skip to main content

Tutorial: Build your own custom field plugin - params/owlimg.xml

Written by Elisa Foltyn

This Joomla! Custom Field Plugin shows images from a selected folder in an "Owl Carousel". In this tutorial, I'll explain to you, how to build your own "Custom Field Plugin".

params/owlimg.xml

With the help of the params/owlimg.xml file we can change the parameters of the field itself. For that, we can copy the fields from the owlimg.xml manifest file and add some more attributes. 

<?xml version="1.0" encoding="utf-8"?>
<form>
	<fields name="fieldparams">
		<fieldset name="fieldparams">

			<field
			       name="customclass"
			       type="text"
			       label="PLG_FIELDS_OWLIMG_CUSTOMCLASS"
			       desc="PLG_FIELDS_OWLIMG_CUSTOMCLASS_DESC"
			       filter="cmd"
			       default="myowl"
			/>

			<field 
			       name="layouthead"
			       type="spacer" 
			       label="PLG_FIELDS_OWLIMG_LAYOUTHEAD"
			/>

			<field
			       name="items"
			       type="number"
			       label="PLG_FIELDS_OWLIMG_ITEMS"
			       min="1"
			       step="1"
			       hint="PLG_FIELDS_OWLIMG_LEAVE_EMPTY"
			/>

			<field
			       name="animatein"
			       type="groupedlist"
			       label="PLG_FIELDS_OWLIMG_ANIMATEIN"
			       showon="items:1"
			       >
				<option value="">COM_FIELDS_FIELD_USE_GLOBAL</option>
					<group label="Attention Seekers">
						<option value="bounce">bounce</option>
						<option value="flash">flash</option>
						<option value="pulse">pulse</option>
						<option value="rubberBand">rubberBand</option>
						<option value="shake">shake</option>
						<option value="swing">swing</option>
						<option value="tada">tada</option>
						<option value="wobble">wobble</option>
						<option value="jello">jello</option>
					</group>
			</field>


...etc

You see that we do not set any default attributes in the params/owlimg.xml because we want to pull the default options from the global parameters of the plugin. Additionally, we add a placeholder (hint), to let the user know that the field has to be left empty to use the global parameters.

Have a look at the params/owlimg.xml file in the download package and compare it with the setup in the manifest file.

It's definitely time we get together!