Former Member
inherit
guest@proboards.com
251770
0
Nov 22, 2024 20:20:02 GMT -8
Former Member
0
January 1970
Former Member
|
Post by Former Member on Jan 29, 2019 13:25:08 GMT -8
I couldn't find much on the subject, but is there any way at all to set a custom field default value?
|
|
SafeInSanity
Junior Member
Falling in love with Proboards again!
Posts: 424
inherit
23917
0
Feb 27, 2020 11:29:13 GMT -8
SafeInSanity
Falling in love with Proboards again!
424
May 2004
wiki
|
Post by SafeInSanity on Jan 30, 2019 8:25:30 GMT -8
|
|
#eb7100
33409
0
1
Nov 13, 2024 16:56:46 GMT -8
Brian
48,130
November 2004
smashmaster3
|
Post by Brian on Jan 30, 2019 9:36:33 GMT -8
This isn't currently possible. Sorry.
|
|
inherit
96289
0
May 17, 2020 9:37:00 GMT -8
elli
1,822
January 2007
ebbymac
|
Post by elli on Jan 30, 2019 10:09:50 GMT -8
I had it in my head that you could do this with a conditional, but I can't find an example in any of my themes, which means I probably tried it at some point and it didn't work. {foreach $[user.custom_field]} {if $[user.custom_field.name] == "Name"} <p><strong>Name:</strong></p> <p>{if $[user.custom_field.value]}$[user.custom_field.value]{else}Default Value{/if}</p> {/if} {/foreach}
You could probably work this out with a little script, though. Have the default value in the container to start, and if the content for $[user.custom_field.value] is in the DOM, then swap the default value with that.
|
|
Former Member
inherit
guest@proboards.com
251770
0
Nov 22, 2024 20:20:02 GMT -8
Former Member
0
January 1970
Former Member
|
Post by Former Member on Feb 2, 2019 0:38:52 GMT -8
Thank you everyone who jumped in on this. <3 I've been tweaking with this, but can't get it to work, so you might be right about the else tags, Elli. I'm going to pop my code up just in case there's something else I can do here:
I'm trying to set a default image link for the website profile overlay for members who haven't set their own links/images.
{foreach $[user.mini_custom_field]} {if $[user.mini_custom_field.name] == "Mini Profile Overlay"} <div class="container25">
<div style="border:solid 2px #000000;width:170px;height:370px;overflow:auto;padding:4px;background-size: cover;background-image: url($[user.mini_custom_field.value]);"> </div> {/foreach}
|
|
inherit
96289
0
May 17, 2020 9:37:00 GMT -8
elli
1,822
January 2007
ebbymac
|
Post by elli on Feb 2, 2019 11:10:02 GMT -8
Oh, that one's a little easier. You can use CSS! In your stylesheet do: .container25 { background-image: url('defaulturl.jpg'); background-size: cover; width: 170px; height: 370px; border: solid 2px #000000; padding: 4px; overflow: auto; }
And then the inline style set by the custom field will overwrite that: {foreach $[user.mini_custom_field]} {if $[user.mini_custom_field.name] == "Mini Profile Overlay"} <div class="container25" style="background-image: url($[user.mini_custom_field.value]);"></div> {/if} {/foreach}
|
|
Former Member
inherit
guest@proboards.com
251770
0
Nov 22, 2024 20:20:02 GMT -8
Former Member
0
January 1970
Former Member
|
Post by Former Member on Feb 5, 2019 14:41:08 GMT -8
Thank you so much elli! I'm having a hard time getting it to work still, though. These are my codes, but the icon still only shows up if there's a custom field, and just doesn't show up at all otherwise. The custom fields in this instance are in the post template, but they behave the same when tweaked for the mini profile too. Thank you for your help so far! <center>{foreach $[post.created_by.custom_field]} {if $[post.created_by.custom_field.name] == "First Icon"} <div class="firstcharicon" style=" background-image: url($[post.created_by.custom_field.value]);">icon</div>{/if}{/foreach}</center> .firstcharicon{ width: 100px; height: 100px; overflow: auto; padding: 4px; border: solid 2px #17181d; background-image: url(https://images2.imgbox.com/d8/a9/fqY9JDZo_o.png); background-size: cover; }
|
|
inherit
96289
0
May 17, 2020 9:37:00 GMT -8
elli
1,822
January 2007
ebbymac
|
Post by elli on Feb 5, 2019 15:04:24 GMT -8
Oh, I see what you want. We have to make the template a little gross to do that... Try this: <div class="firstcharicon" style="background-image: url({foreach $[user.mini_custom_field]}{if $[user.mini_custom_field.name] == "First Icon"}$[user.mini_custom_field.value]{/if}{/foreach});"></div>
The syntax highlighting will complain about this as though there's an error, but it should work.
|
|
Former Member
inherit
guest@proboards.com
251770
0
Nov 22, 2024 20:20:02 GMT -8
Former Member
0
January 1970
Former Member
|
Post by Former Member on Feb 5, 2019 15:09:02 GMT -8
Hmm, that solved the issue of the border, but the icon both for an empty field and filled custom are missing. ;w; Sorry for the trouble and thank you for the help.
|
|
inherit
96289
0
May 17, 2020 9:37:00 GMT -8
elli
1,822
January 2007
ebbymac
|
Post by elli on Feb 5, 2019 15:14:31 GMT -8
At the very least, your CSS should be applying the default icon. Are you able to see if that's happening using developer tools?
|
|
Former Member
inherit
guest@proboards.com
251770
0
Nov 22, 2024 20:20:02 GMT -8
Former Member
0
January 1970
Former Member
|
Post by Former Member on Feb 5, 2019 15:19:45 GMT -8
It applies if there's no {if}s affecting it, but the moment custom fields come into play it tends to go blank.
|
|
inherit
96289
0
May 17, 2020 9:37:00 GMT -8
elli
1,822
January 2007
ebbymac
|
Post by elli on Feb 5, 2019 15:26:27 GMT -8
Oh, shoot, I put the foreach and if in the wrong place. This is basically creating a background image with an empty value, which is overwriting your CSS (as intended, but it shouldn't happen unless the field is filled out). mb ;_; Try this:
<div class="firstcharicon" style="{foreach $[user.mini_custom_field]}{if $[user.mini_custom_field.name] == "First Icon"}background-image: url($[user.mini_custom_field.value]);{/if}{/foreach}"></div>
|
|
Former Member
inherit
guest@proboards.com
251770
0
Nov 22, 2024 20:20:02 GMT -8
Former Member
0
January 1970
Former Member
|
Post by Former Member on Feb 5, 2019 15:32:39 GMT -8
Thank you so much, Elli! It worked perfectly, thank you so much for your help, this was driving me crazy! <3 <3
|
|