inherit
118283
0
Oct 24, 2020 6:55:22 GMT -8
Ishy
470
February 2008
april7291
|
Post by Ishy on Dec 21, 2017 9:28:10 GMT -8
I'm trying to customize the User Profile page and I want to include specific custom fields that are links. I'm using icons as the links. Currently, if the icon has a link attached to it the icon shows, but when I remove the attached link then the icon doesn't show. I want the icon to be showing even if there isn't a url attached to it. I've tried various methods of {if} statements and I just can't seem to get it right. For example, the application and plotter icons show because there is a link attached but the want ad doesn't. Link
|
|
#e61919
Support Staff
224482
0
1
Nov 22, 2024 17:59:24 GMT -8
Scott
“Asking for help isn't giving up... it's refusing to give up.”
24,521
August 2015
socalso
|
Post by Scott on Dec 21, 2017 9:42:00 GMT -8
Ishy, Might be helpful to post the code you are using (please put in spoiler tags), and where you're putting the code on the forum (which layout template(s), headers/footers). Any screen shots of what is/isn't working?
|
|
inherit
118283
0
Oct 24, 2020 6:55:22 GMT -8
Ishy
470
February 2008
april7291
|
Post by Ishy on Dec 21, 2017 12:57:45 GMT -8
It's located in the User Profile page, within the Summary tab. The star and sitemap icons show because there are links attached to them from my profile but the one that's supposed to appear above the 'want ad' doesn't show because there is no link attached. I want there to be a default icon there even if there is no link attached. And when someone edit's their profile to include a link, that icon becomes a clickable link. <td style="border-right: 1px solid #ddd;"> {foreach $[user.mini_custom_field]}{if $[user.mini_custom_field.name] == "Application"} <div class="custom1"> <a href="$[user.mini_custom_field.value]"><i class="fa fa-star" aria-hidden="true"></i></a> </div> {/if}{/foreach} <div class="custom2"> Application </div> </td> <td style="border-right: 1px solid #ddd;"> {foreach $[user.mini_custom_field]}{if $[user.mini_custom_field.name] == "Plotter"} <div class="custom1"> <a href="$[user.mini_custom_field.value]"><i class="fa fa-sitemap" aria-hidden="true"></i></a> </div> {/if}{/foreach} <div class="custom2"> Plotter </div> </td> <td> {foreach $[user.mini_custom_field]}{if $[user.mini_custom_field.name] == "Want Ad"} <div class="custom1"> <a href="$[user.mini_custom_field.value]"><i class="fa fa-heart" aria-hidden="true"></i></a> </div> {/if}{/foreach} <div class="custom2"> Want Ad </div> </td>
|
|
#eb7100
33409
0
1
Nov 24, 2024 4:27:37 GMT -8
Brian
48,130
November 2004
smashmaster3
|
Post by Brian on Dec 21, 2017 15:45:38 GMT -8
There's unfortunately no way to output HTML based on a custom field not being present.
The foreach loop for custom fields only loops through all of the custom fields that have been filled out. If a custom field isn't filled out the page disregards it as nonexistent and doesn't include it in the loop at all, so there's nothing that can be added to the loop to tell it to output something different if the field doesn't exist with it.
|
|
inherit
118283
0
Oct 24, 2020 6:55:22 GMT -8
Ishy
470
February 2008
april7291
|
Post by Ishy on Dec 21, 2017 16:46:09 GMT -8
Alright, I understand. I really appreciate your help. Thank you and have a Merry Christmas!
|
|
Kami
Forum Cat
Posts: 40,199
Mini-Profile Theme: Kami's Mini-Profile
#f35f71
156500
0
Offline
Jul 24, 2021 11:48:29 GMT -8
Kami
40,199
July 2010
kamiyakaoru
Kami's Mini-Profile
|
Post by Kami on Dec 21, 2017 17:03:45 GMT -8
You could wrap an in-line style or a class in a conditional if the field DOES exist so that the element is hidden. Then you can wrap another element with the same condition so that it shows when the other element is hidden.
EG:
<div {if statement here}style="display:hidden;"{/if}> the stuff to display if no fiel</div>
{if statement here} the content you want to appear if the field is filled {/if}
|
|