Fields in jDownloads

Introduction

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 may be multilingual. But note that the Fields and Field Groups discussed here are those that have been created in jDownloads.

Field titles and contents are displayed in the frontend  using placeholders {jdfield_title id} and {jdfield id} where id is the relevant id of the required Field created in jDownloads.

Please ensure that there is only a single space between jdfield_title and the id value, simarly just a single space between jdfield and the id value.

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 when editting in the frontend all the Fields in a Field Group are shown in a single tab.

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 the Field Group is Published and the Language is set appropriately.  Leave as All unless you have a multilingual site.

Also set the 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

Fields

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 initially show details of creating a Text  type as that covers most required fields.  Field types like Text and Colour only have one Text and one Value to enter.  Later we also show creating a Radio field as it has multiple text/value possibilities.

General tab

On the General tab, as shown opposite, give a suitable title. In this article we have used 'Text Field 1'.  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 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.
field text01

When there is no Default Value then the Field will not be shown until it is editted and given a value in the relevant Download.

If you do specify a Default 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!

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 Display setting.

The items in the 'Form Options' section allow styling how the text and value will appear also 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

field02'

Publishing Tab


The Publishing Tab allows setting or changing the created Date.

The Created By, Modified Date and Modified By entries  are auto filled.

field03-Publish Tab'

Permissions Tab

The default setting for permissions is that they are inherited from the Permissions set in the Field Group.  But they do need to be set separately 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.

Radio Field Example

Setting up the Options, Publishing and Permissions tabs is similar in all Field types.
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

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

Diferent views occur for non-multilingual sites, where all content has ALL for the Download Language, and Multilingual sites which use language specifiers such as {de-DE}.

ALL type language sites

As illustrated below if the language field is set for ALL then when editting the 'language' Field Groups as well as the ALL Field Group are shown.  This is to enable consistency across languages for the 'answer'.

But of course when showing in a non multi language site only the Field Groups set to ALL are shown.

Multilingual sites

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 below.  In a 'pure' multilingual site there would be no ALL Field Group.

In the first two examples there are tabs for the current language and for All.

For a 'pure' multilingual site there would be no 'All' tab.


The first one is where the Download was set to English.
edit-multilang01


The second one is where the Download was set to the German language.

edit-multilang02
The third example is slightly different as it has an All tab together with English, French and German Fields tabs.

edit-multilang03
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

Showing jDownloads fields in the front end is only available in a Download or Download Details layout information block;

The Downloads use the place holders {jdfield_title id} and {jdfield id} where id is the relevant id of the required field.
In this example the Fields are 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 to select the appropriate one.

The image opposite shows part of a Compact Layout that has been modified to support two Fields in mutiple languages.

The whole of the en-GB section and part of the de-DE section is shown.

With this method there are no 'blank spaces' shown in the front-end for the other languages.
field multilang03
 
The image opposite shows an fr-FR information block in a multilingual site

field FR01

Colin M  March 2020, updated May 2021, March 2022

Tags: index

Print Email