We hope you enjoy your visit.

You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Locked Topic
[ C ] Favourite colour BBCode
Topic Started: Jan 15 2015, 03:57 PM (296 Views)
HIRP
Member
[ * ]
Board Address: Link
Board Software: ZB
Description:

I feel like this should be pretty simple but I could be wrong. I'm looking for a custom BBCode that can insert a [ color = x ] tag into a post and use a preset colour that is set in a user's profile. I imagine using a custom profile field would be easiest.

Example: I set up a "Post Color" custom profile field. I then go to my profile and put "red" into the field. Then, in a post, I write this:

Code:
 
My favourite colour is [c]this.[/c]

Which would come out looking like this:
Quote:
 
My favourite colour is this.

Essentially what I'm looking to do is have my members select a post colour in their profiles, which will then be substituted into their posts whenever they use the [c] tag. Any help would be appreciated!

Edit: the profile field input should accept anything that would be acceptable within a [ color = ] tag, so names ("red", "seagreen") and hexcodes ("#cc0000").
Edited by HIRP, Jan 15 2015, 03:59 PM.
Offline Profile Goto Top
 
Cory
Member Avatar
Member
[ *  *  *  *  *  *  *  *  * ]
Admin CP Posted Image Users & Groups Posted Image Profile Fields

Create a 1 line text field with these settings:

Title: Post Color
On Registration: Your Choice
Show field in topics: Yes
Admin Only Edit: No
Maximum input length: Your Choice

Admin CP Posted Image Themes Posted Image Board Template Posted Image Below the Board
Code:
 
<script type="text/javascript">
//<![CDATA[
$('dl.user_profile dt:contains(Post Color)').each(function() {
$(this).next('dd').andSelf().hide();
var color = $(this).next('dd').text();
$(this).parents('td.c_user').next('td.c_post').html($(this).parents('td.c_user').next('td.c_post').html().replace(/\[c\](.+?)\[\/c\]/ig, '<span style="color: ' + color + '">$1</span>'));
});
//]]>
</script>
Offline Profile Goto Top
 
HIRP
Member
[ * ]
Thanks a lot, Cory. I'm wondering, is it possible to either hide the profile field from plain view in threads or otherwise make it so that the "Show field in topics" option does not need to be enabled?

Right now I've got another piece of code that manually re-orders the profile fields I've got set up (you actually wrote it for me a few years ago), and because it doesn't account for the new "Post Color" field, it seems to be hidden away as far as I can tell, but I'm wondering if it would be possible to move forward with the option disabled so I can avoid anything on my forum exploding in the future.

Example thread here. Notice how the "Custom Color" profile is not displayed? It is enabled in the admin CP, but not shown probably due to the other piece of code that's swapping the fields around. Would it be possible to make the code above work without the "Show field in topics" option enabled just to be safe?

Edit: Here's the code I'm running that also dinks with the profile fields.

Code:
 
<script type="text/javascript">
(function($) {
var order = ["Character Age","Year","Alma Mater","Position","Blood Status","RP Relationship Status","Real Name","Gender","Age","Location"];
/* Stop Editing! */
$("dl.user_profile").each(function() {
var t = $(this),
c = t.children("dt"),
a = [];
c.each(function() {
var y = $(this);
$.each(order,function(i,v) {
if (y.text() === v)
a[i] = ["</dd>",y.next().remove().html(),"</dt><dd>",y.remove().html(),"<dt>"].reverse().join("");
});
});
t.prepend(a.join(""));
});
})(jQuery);
</script>


<script type='text/javascript'>
$('dl.user_profile').each(function () {
$('dt:contains(Character Age), dt:contains(Alma Mater), dt:contains(Blood Status), dt:contains(RP Relationship Status), dt:contains(Position), dt:contains(Year)', this).eq(-1).next().after('<br />');
});
</script>
Edited by HIRP, Jan 16 2015, 09:28 PM.
Offline Profile Goto Top
 
Cory
Member Avatar
Member
[ *  *  *  *  *  *  *  *  * ]
Code:
 
$(this).next('dd').andSelf().hide();
That's what is hiding the field from appearing in the mini profile. I'm not entirely understanding what the issue is and why it would conflict with that code.

It's essential the "Show field in topics" option is enabled, otherwise a lot of AJAX would have to be used.
Offline Profile Goto Top
 
HIRP
Member
[ * ]
Ah! I hadn't realized that the code you gave to me hid it by itself. Good thinking. I was just worried that there might have been something conflicting with the existing code.

Great work as always. Thanks again.
Offline Profile Goto Top
 
Helena
Member Avatar
M is for Mod

Completed!

Your request has been completed. If you have any questions or concerns regarding the state of your request, please feel free to contact me via PM.
Offline Profile Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Closed Requests · Next Topic »
Locked Topic