Fields in jDownloads


jDownloads 3.9 and higher releases support Joomla! Fields.  These are more powerful and have more types than the jDownloads Custom Fields available in earlier jDownloads releases.  One consequence is that the 3.2 Custom Fields are no longer supported in jDownloads 3.9.

When upgrading from the jD3.2 series to the 3.9 series the old style jD Custom fields are automatically converted to Joomla Fields.

Also of course Fields and Field Groups are fully integated in Joomla!  and they may be multilingual.

Creating Fields and Field Groups

In this example we will first create a Field Group as placing Fields in a group simplifies using them when subsequently creating or editing Downloads.  One instance is that when creating a Field then the permissions are taken from those set in its Field Group.  Another is that

Fields do not have to be in a Field Group, in effect when not in an explicit group they then belong in the 'ungrouped' group!

Field Groups

Select button fieldgroup in the jDownloads Control Panel and then click on button new.  The Field Group Create panel will appear.

Give the group a suitable Title which in this example is 'Field Group1-ALL'.
Note:The ALL  is my convention here to denote that the default language setting  'All' has been used. Later in this article, in the multilingual section, there are three more Field Groups called 'Field-Group-EN', 'Fied-Group-FR' and 'Field-Group-DE' for Enlish, French and German languages respectively.

General tab

In the General tab ensure it is Published and the Language is set appropriately.  Leave as All unless you have a multilingual site.

Also set Access as required, which would usually be Public.

Give the group a Description as that will guide users in the Frontend who are able to edit fields.

Also add a comment in the Note as that will appear in the Backend.

field group01

Publishing tab

The settings in the Publishing tab are self explanatory.

The only setting that can be changed is the 'Created Date'.

The other options are filled automatically.

field publish tab

Options tab

The Options tab has just one setting 'Display When Read-Only'. field options tab

This is best left at the default value 'Yes'.  This setting will, by default, be inherited by any Field that is a member of the Field Group.

Permissions tab

On the Permissions Tab set up the relevant permissions for those User Groups that are to be allowed to create/edit in the Front End.

The default permission for front end users is butt not allowed so if you want Frontend users in a specific user-group to be able to manage Fields then you need to setup the permissions appropriately.

One of the significant features of Field Groups is that these permissions will then be inherited by all the Fields that belong to the Field Group.
fields permissions02


The next step is to create the relevant Fields.  In this example there are three Fields, a simple 'Text' field, a 'Colour' field and a 'Radio' field.

So select  button field and then click on button new which will open the Fields create/edit form.  Here we show just details of creating the Radio type as that is the most 'interesting' one as it has multiple text/value possibilities.

General tab

On the General tab of the form, as shown below, give a suitable title. In this article we have used 'Radio Field-ALL'.  Note that this will also automatically fill the 'Label' option.  When the Field is Saved then the Name option, which is like the 'alias', will be generated from the title.
The Type Field pulldown sets the type of the field from the pulldown list of those available. Once saved it cannot be changed.
It is strongly suggested that you leave the Default Value option empty. When there is no Default Value then the Field will not be shown until it is edited and given a value in the relevant Download. If you do specify a Defaut Value then this value will appear in all Downloads that have not had an explicit value entered.

Ensure you set the Field Group by using the pull down.

Important!! Always leave the Category as All as Joomla! only supports its own article categories!

To add the Radio Text and Values click on the button-add button for each radio button you wish to have.  Enter in the  Text  column the 'question' that the user will see, and in the Value column specify the vaue, which is actually text, that will be returned to the code when the button is selected in the front end.

Field types like Text and Colour only have one Text and one Value to enter.

custom convert10

Options Tab

The Options tab basically deals with how the Field text and value are to be shown in the Front End, but note the Automatic Diaplay setting.

The items in the 'Form Options' section allow styling how the text and value will appear in the Edit Form.

The settings in the 'Render Options' section mainly style the look of the Text and Value as they are to appear in the frontend view.

However the Automatic Display setting controls where the text and value will appear in the Front End.  This is discussed in more detail later.

As a starting point it is strongly suggested the 'Automatic Display' option is set to 'Do not Automatically Display'.

And then do a button save


Publishing Tab

The Publishing Tab allows setting created Date, Created By and similar.  In general these are auto filled.

Permissions Tab

The Default setting for the permissions inherit the Permissions set in the Field Group.  But they do need to be set if the Field is not in a Field Group.  If the Fields have been 'imported' from the 'custom fields'  of jD 3.2 site then you will need to set the permisions on every field type separately.

Multilingual notes

Setting up Fields and Field Groups in a multilingual site is just the same except one selects the Language appropriately. 

In this example as well as the All group, three language Field Groups were created: English, French And German as illustrated opposite.
field group02
In a multilingual site only those of the same language as currently in use and the All languge items are shown in the frontend.

Thus when editing or creating a Download there will be 'tabs' for the 'All' group and the relevant language.  If there are 'ungrouped' fields then they will also have a tab.  In practice a true multilingual site would not have the 'All' set; and in a non multilingual site there would normally only the 'All' setting would be used as the language selector.

Editing in Frontend

Example views of the tabs that are present when editing/creating a Download in the frontend for a mixed multilingual and 'All' site are shown opposite.

The first one is when the Download was set to English  and the second one is when the Download was set to German language.  In both cases there are tabs for the current language and for All.

The third one was when editing a Download whose language was 'All'.  In this case as well as the All tab the English, French and German Fields tabs are also shown.

Each tab in the edit form for the four Field Groups is shown opposite. 

In this example the 'All' and the 'English' version happen to be identical.  Actually the 'French' and 'German' are also logically identical to the others.  This was not done by Joomla! or jDownloads but by the author for consistency.

custom convert10edit en01edit de01edit fr01
One is free to set completely different 'questions' and response values.

Whilst the response values would be different in different Downloads, it is clearly good practice to make the 'question' text logically identical across languages.

Viewing Fields in Frontend

There are three situations for showing jDownloads fields in the front end
(i)   in a layout innformation block
(ii)  in a Download Description
(iii) in an article
The Downloads use the place holders {jd_field_title id} and {jd_field id} where id is  the relevant id of the required field.

In Layouts

In this example the Fields were shown as part of the Information section of the Compact layout. 

The image opposite is the view shown in the frontend view.

The second image is the modified code in the Compact Layout.

The parts referring to fields have been highlighted

field all01edit all02
The situation with Fields in multilingual sites is similar but to work properly you need to use the jDownloads multilingual placeholders like {en-Gb}, {de-DE} and so on.

The image opposite shows a part of the Compact Layout that has been modified to support English, French and German fields.

field multilang02field FR01

In an Article

The Joomla! Content-Fields plugin has two placeholders for use in articles
(i) field id03 shows an individual field and (ii)field group03to show the whole field group, that is all the fields in that group.
For example field id04 shows the field title and the field value with id 13;
field group04 lists all the fields in the field group with id 2 .

In the example shown opposite each field had the 'Automatic Display' option set to 'Do not automatically display'.
content field03

The effect of changing the 'Automatic Display' option to one of the other settings, such as 'Before Display' is shown opposite.

The 'Automatic Display' settings will also show the fields in Downloads but this is rarely useful.

content field04
Much greater flexibility is achieved through the field id03 and field group03 place holders.

Colin M  March 2020, updated May 2021

Tags: index

Print Email