News:

Support for jDownloads 3 has been ended
Since 17 August 2023 Joomla.org has discontinued support for Joomla 3.x. Therefore, we will no longer offer official support for our Joomla 3 jDownloads version 3.9.x from January 2024.
Please update your website to the latest Joomla version (Joomla 4 or Joomla 5) as soon as possible. Afterwards, please update jDownloads to the latest published version. The longer you delay, the more difficult the upgrade process for your website is likely to be.

Main Menu
Support-Forum

Hiding Placeholder Variables When They the Custom Field is Empty

Started by Bilal Abdeen, 28.04.2020 11:23:07

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Bilal Abdeen

Thank you for the excellent extension.

It will be great if placeholder variables for custom fields, which are used in layouts, are hidden when the relevant custom fields have no values (not populated with data).

For example, I will define a custom field called "custom_field_1." Some downloads have the value for this field populated, while other downloads have the value empty. I want the placeholder variables {custom_title_1} & {custom_value_1} to be displayed for downloads, which have the value populated, and hidden for the downloads, which have the value empty.

<!-- The following statement should display nothing if the custom_field_1 is empty for this dowload -->
{custom_title_1} {custom_value_1}

I understand that if {custom_field_1} is not defined at all, the placeholder variables are not be displayed.

Thanks
  •  

ColinM

HiThere are two aspects here.  Firstly the jD Custom Fiellds in jD3.2 series are being replaced by the use of Joomla! Fields.  When upgrading to version 3.9, which is in beta test, existing jD custom fields are automatically converted to corresponding Joomla! Field.
There are equivalent ways to show those in Layouts - placeholders {jdfield_title 'id'} and {jdfield 'id'}.  At the moment these suffer from the same problem as you have identified..  Some time ago I lodged a request that if  {jdfield 'id'} was 'empty' then there should be an option to not show {jdfield_title 'id'}.  This is not as easy as it sounds as some users like to show the title when the field value is not set.  Field values are also slightly more complex as they can have a default value.
Colin
Colin M
  •