Post by Kami on Feb 9, 2020 20:12:23 GMT -8
OK! Sorry for the delay, mysticrystal . This is a bit of a hacky workaround, and comes with a major caveat: there is a limit of 30 foreach loops per template so you can't use with complete abandon. As long as you limit yourself to 30 custom fields or less, you should be good.
The structure in admin > structure > layout templates > mini profile is as follows; place this wherever you want your custom fields to appear in the MP.
Field Name: <span {foreach $[user.mini_custom_field]}{if $[user.mini_custom_field.name] == "Field Name"}style="display:none;"{/if}{/foreach}>This is a default answer if blank</span>{foreach $[user.mini_custom_field]}{if $[user.mini_custom_field.name] == "Field Name"}$[user.mini_custom_field.value]{/if}{/foreach}
To break it down:
Field Name - (Field Name, Blue) Write the field name here in plain text. You don't want to use the default text that's generated by the custom field options, because you want this section to appear regardless of whether or not it's filled out.
Field Name - (Field Name, Green, both instances) This will again need to be the field name. This is cAsE sEnSiTiVe so you will need to put the exact thing you wrote in the custom fields options. "Name" will not trigger if you write "name" and so on.
This is a default answer if blank - Put whatever you want the "default" value to be here.
How this works: I wrapped the span style of style="display: none;" in a {foreach} loop that calls out a specific field name. If the field isn't filled out, as Brian mentioned, the field name doesn't appear at all, which means that the style will also similarly, not appear. This allows you to display a "default" value (as you've specified). If the field IS filled out, since that variable now exists, the span style also triggers and therefore hides your "default" value.
You will have to do this for each individual field you want to have a default value - you cannot try and leave out the field name and just use an if/else to determine if the field is filled out in general, or it will trigger if ANY field is filled out as a whole. In other words, if you want a default value for Field A and for Field B and you try to shortcut it without specifying each field individually, the default value will disappear regardless of whether or not it's been filled in.
Here is a working example: kamitest5.proboards.com/thread/2/asdasdas?page=1&scrollTo=25
The Kami account has one field filled out, but not the other. The kamitest account has both fields filled out.
Hope this helps!
The structure in admin > structure > layout templates > mini profile is as follows; place this wherever you want your custom fields to appear in the MP.
Field Name: <span {foreach $[user.mini_custom_field]}{if $[user.mini_custom_field.name] == "Field Name"}style="display:none;"{/if}{/foreach}>This is a default answer if blank</span>{foreach $[user.mini_custom_field]}{if $[user.mini_custom_field.name] == "Field Name"}$[user.mini_custom_field.value]{/if}{/foreach}
To break it down:
Field Name - (Field Name, Blue) Write the field name here in plain text. You don't want to use the default text that's generated by the custom field options, because you want this section to appear regardless of whether or not it's filled out.
Field Name - (Field Name, Green, both instances) This will again need to be the field name. This is cAsE sEnSiTiVe so you will need to put the exact thing you wrote in the custom fields options. "Name" will not trigger if you write "name" and so on.
This is a default answer if blank - Put whatever you want the "default" value to be here.
How this works: I wrapped the span style of style="display: none;" in a {foreach} loop that calls out a specific field name. If the field isn't filled out, as Brian mentioned, the field name doesn't appear at all, which means that the style will also similarly, not appear. This allows you to display a "default" value (as you've specified). If the field IS filled out, since that variable now exists, the span style also triggers and therefore hides your "default" value.
You will have to do this for each individual field you want to have a default value - you cannot try and leave out the field name and just use an if/else to determine if the field is filled out in general, or it will trigger if ANY field is filled out as a whole. In other words, if you want a default value for Field A and for Field B and you try to shortcut it without specifying each field individually, the default value will disappear regardless of whether or not it's been filled in.
Here is a working example: kamitest5.proboards.com/thread/2/asdasdas?page=1&scrollTo=25
The Kami account has one field filled out, but not the other. The kamitest account has both fields filled out.
Hope this helps!