The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

Profile Field Answer Color

View previous topic View next topic Go down

Solved Profile Field Answer Color

Post by Rhaenys on December 20th 2014, 10:33 pm

Hello. I have looked and looked and looked and can't find the answer so I thought I would ask. If I somehow missed the thread that had the answer, I apologize.

I would like to change the ANSWER field of some of my profile fields to be a certain color. For example, the members of my alliance can pick the type of Dragon they have in a particular game. One is red, one is green and one is tan. I would like for when they pick the Green Dragon, for the wording to be Green. I've tried everything I know of and can't get it to work. Any ideas? I can do this easily in the RPG fields, but I can't find a way to do it in the actual profile fields that I can have show up when someone makes a post.



This is on the RPG field, and how it's supposed to be.



This is on the regular profile, and what I would like fixed.


Thanks in advance for any help.


Last edited by Rhaenys on December 23rd 2014, 3:43 am; edited 1 time in total

Rhaenys
New Member

Posts : 13
Reputation : 2
Language : English

http://fireandblood.forumotion.com/

Back to top Go down

Solved Re: Profile Field Answer Color

Post by Ange Tuteur on December 21st 2014, 1:03 am

Hello @Rhaenys,

I have some questions :

  • Your forum version is phpbb3, correct ?
  • What type of profile field is it ?

By type I mean, is it a text field, image list ?


Lastly, do you want just the profile field text to be the color of their choice, or the entire profile texts ?

Ange Tuteur
Forumaster

Male Posts : 13021
Reputation : 2683
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: Profile Field Answer Color

Post by Rhaenys on December 21st 2014, 2:39 am

It is a list on this particular one, but I also have a text field I want done. The image is another field as I couldn't get it to do a image and text together. Yes you have the forum type correct. I'm sorry I don't quite understand your 3rd part. If your mean where you can pick a color on the profile field this is not what I want. I know how to do that, but it's the ANSWER I want to change colors of.

Rhaenys
New Member

Posts : 13
Reputation : 2
Language : English

http://fireandblood.forumotion.com/

Back to top Go down

Solved Re: Profile Field Answer Color

Post by Ange Tuteur on December 21st 2014, 3:43 am

See if this is what you want :

Go to Administration panel > Modules > JavaScript codes management > Create a new script

Title : Your choice
Placement : In the topics
Paste the code below :
Code:
$(function() {
 fieldColor('image','field name','red');
 fieldColor('image','field name','green');
 fieldColor('image','field name','tan');
 
 function fieldColor(img, name, color) { $('.postprofile:has(img[src="'+img+'"])').find('span.label:contains('+name+')').css('color',color) };
});

So the text of the field can be colored you need to fill in some fields in the script above. Where it says image replace those texts with the image of your dragons. Where it says field name insert the name of the profile field, exactly as it was written. I already filled in the color part, but you can change the colors if you want.

When finished, save.

Ange Tuteur
Forumaster

Male Posts : 13021
Reputation : 2683
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: Profile Field Answer Color

Post by Rhaenys on December 21st 2014, 4:57 pm

Ok, I did that I think. But it still doesn't work. Here is the Java script

Code:
$(function() {
  fieldColor('http://i39.servimg.com/u/f39/18/85/66/12/green_11.png','Qeldie Rūs Zaldrīzes Ko','green');
  fieldColor('image','field name','green');
  fieldColor('image','field name','tan');
 
  function fieldColor(img, name, color) { $('.postprofile:has(img[src="'+img+'"])').find('span.label:contains('+name+')').css('color',color) };
});

I only did one so far to see if it would work. I'm not sure if you wanted me to change any of the bottom part or not. Sorry.

Rhaenys
New Member

Posts : 13
Reputation : 2
Language : English

http://fireandblood.forumotion.com/

Back to top Go down

Solved Re: Profile Field Answer Color

Post by Ange Tuteur on December 22nd 2014, 1:03 am

Yeah that's correct, I think it might have to do with the child node having a color which is why it didn't turn green.

Replace your script with this and it should work :
Code:
$(function() {
 fieldColor('http://i39.servimg.com/u/f39/18/85/66/12/green_11.png','Qeldie Rūs Zaldrīzes Ko','green');
 fieldColor('image','field name','green');
 fieldColor('image','field name','tan');
 
 function fieldColor(img, name, color) { $('.postprofile:has(img[src="'+img+'"])').find('span.label:contains('+name+'), span.label:contains('+name+') *').css('color',color) };
});

Ange Tuteur
Forumaster

Male Posts : 13021
Reputation : 2683
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: Profile Field Answer Color

Post by Rhaenys on December 22nd 2014, 1:26 am

Nope. Sad At least I know it wasn't just me that couldn't get it to behave like I wanted. Here's what I've got just in case I'm missing something easy. Thanks.




Rhaenys
New Member

Posts : 13
Reputation : 2
Language : English

http://fireandblood.forumotion.com/

Back to top Go down

Solved Re: Profile Field Answer Color

Post by Ange Tuteur on December 22nd 2014, 2:25 am

Oooh, you're using a list. The script I gave you was for a image list, sorry Embarassed

Replace the script I gave you, by the one below.
Code:
$(function() {
 listColor('Qeldie Rūs Zaldrīzes Ko','#080');
 listColor('labelName','colorChoice');
 listColor('labelName','colorChoice');
 
 function listColor(name, color) { for (var i=0,a=document.getElementsByTagName('DIV'); i<a.length; i++) if (/postprofile/.test(a[i].className) && new RegExp(name).test(a[i].innerHTML)) a[i].innerHTML = a[i].innerHTML.replace(new RegExp(name),'<span style="color:'+color+'">'+name+'</span>') }
});

It's the same except we'll just use the list text. labelName is the name of the choice (Qeldie Rūs Zaldrīzes Ko), and colorChoice is the color code or name that you want it to be.

Ange Tuteur
Forumaster

Male Posts : 13021
Reputation : 2683
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: Profile Field Answer Color

Post by Rhaenys on December 22nd 2014, 4:36 pm

Well, that worked except one thing. :/ I should have mentioned probably that there are ttechnically 4 types of Dragons. Plain, Green, Red and Tan. The plain one is "Rūs Zaldrīzes Ko" which means Baby Dragon Protector, and then you add Green "Qeldie" ahead of it for Green Baby Dragon Protector. It makes the "Qeldie" green, but the rest of it uses the plain baby Dragon coloring. So all of them are 2 colors now. :/ Is there any way to force it to see the whole thing as one instead of 2 separate names? If not I'll just have to come up with another title. Thanks.


Rhaenys
New Member

Posts : 13
Reputation : 2
Language : English

http://fireandblood.forumotion.com/

Back to top Go down

Solved Re: Profile Field Answer Color

Post by Ange Tuteur on December 23rd 2014, 1:53 am

I didn't think of that, replace the script with this :
Code:
$(function() {
  listColor('Qeldie Rūs Zaldrīzes Ko','#080');
  listColor('labelName','colorChoice');
  listColor('labelName','colorChoice');
  listColor('labelName','colorChoice');
  listColor('Rūs Zaldrīzes Ko','colorChoice');
 
  function listColor(name, color) { for (var i=0,a=document.getElementsByTagName('DIV'); i<a.length; i++) if (/postprofile/.test(a[i].className) && new RegExp(name).test(a[i].innerHTML) && !/listItemCustomColor/.test(a[i].innerHTML)) a[i].innerHTML = a[i].innerHTML.replace(new RegExp(name),'<span class="listItemCustomColor" style="color:'+color+'">'+name+'</span>') }
});

I added a check for if the color has been changed, but I would still put "Rūs Zaldrīzes Ko" as the last if it's used in multiple choices. Like I did above.

Ange Tuteur
Forumaster

Male Posts : 13021
Reputation : 2683
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: Profile Field Answer Color

Post by Rhaenys on December 23rd 2014, 3:42 am

Thank you so much. Smile

Rhaenys
New Member

Posts : 13
Reputation : 2
Language : English

http://fireandblood.forumotion.com/

Back to top Go down

Solved Re: Profile Field Answer Color

Post by Ange Tuteur on December 23rd 2014, 3:58 am

You're welcome ^^

Topic archived

Happy holidays santa

Ange Tuteur
Forumaster

Male Posts : 13021
Reputation : 2683
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum