View Full Version : Replacing a Colour with FieldID in CSS
Brexen
03-06-2012, 04:56 PM
Hi there.
I would like to make a colour variable in CSS selectable via Profile Fields.
In short, I want to change the following part of my code;
REMOVED by Poster
into;
REMOVED by Poster
So that the value set in ProfileField 2 will become the colour used in the CSS.
I know how to make the List of variables in the Profile Fields however I don't know how to link the Field ID into the CSS.
Normally it would be something like;
REMOVED by Poster
However, I don't think this will work with the CSS. Please correct me if i'm wrong however.
If you want each post author's color selection to be used in the postbit, then you can't put it in the CSS. But you could use it directly in the postbit template.
ETA: or if you must put that info in the CSS and you have a relatively small number of choices, you could make a class for each one then have the dropdown values be the class names, and then use the class name in the postbit template.
Brexen
03-07-2012, 06:30 PM
If you want each post author's color selection to be used in the postbit, then you can't put it in the CSS. But you could use it directly in the postbit template.
ETA: or if you must put that info in the CSS and you have a relatively small number of choices, you could make a class for each one then have the dropdown values be the class names, and then use the class name in the postbit template.
Hey there,
I tried doing what you said, but it's given me an error for some reason.
Here's my CMS;
.ghosthax-blue {
color: #FFFFFF;
font-weight: bold;
text-shadow: 0px 0px 2px #FFFFFF, 1px 0px 1px #000099, 0px -1px 1px #000099, 0px 1px 1px #000099, -1px 0px 1px #000099, 1px 0px 1px #000099;
}
This is what was entered in the Postbit;
{vb:raw post.field21}Status:</span> {vb:raw post.onlinestatus}</div>
This is the Profile Field;
http://screensnapr.com/e/fTggNn.jpg
and here is the outcome;
http://screensnapr.com/e/n5ihND.jpg
Any ideas?
It will look stunning if I can get it working. Any help is appreciated.
You can't include html in profile field options, the special characters get escaped and you get something like you see above. Why don't you just make the choices the color names then in postbit use something like:
<span class="ghosthax-{vb:raw post.field21}">Status:</span> {vb:raw post.onlinestatus}</div>
(of course you could also do this:
<span class="ghosthax" style="color:{vb:raw post.field21}">Status:</span> {vb:raw post.onlinestatus}</div>
then you wouldn't need the separate color classes).
Brexen
03-07-2012, 07:00 PM
You can't include html in profile field options, the special characters gets escaped and you see the result. Why don't you just make the choices the color name then in postbit something like:
<span class="ghosthax-{vb:raw post.field21}">Status:</span> {vb:raw post.onlinestatus}</div>
(of course you could also do this:
<span class="ghosthax" style="color:{vb:raw post.field21}">Status:</span> {vb:raw post.onlinestatus}</div>
then you wouldn't need the classes).
Even better would this work?
<span class="ghosthax-{vb:raw post.field21}">Status:</span>
Then change the options in the Profile field to the colour name, like blue.
Is that right?
Even better would this work?
<span class="ghosthax-{vb:raw post.field21}">Status:</span>
Then change the options in the Profile field to the colour name, like blue.
Is that right?
Yes, I think that should work.
Brexen
03-07-2012, 07:11 PM
Yes, I think that should work.
Ok, next problem. I've changed the ProfileField to the colours now. However, this is the problem I am getting.
http://screensnapr.com/e/Skhr71.jpg
http://screensnapr.com/e/7FcT8E.jpg
It's either, my forum hasn't updated the ProfileField (It's been 5 mins) or something is still not correct =/
If you change the choices I think each user that had a value will have to go to their profile and save it again, or else they'll still have the old value. Also, users that haven't edited their profile since you added that field will have a blank value for that profile field, even if you specified a default, so you'll have to account for that somehow (I suppose you could make a class named "ghosthax-" that's the same as ghosthax-default).
Brexen
03-07-2012, 07:28 PM
If you change the choices I think each user that had a value will have to go to their profile and save it again, or else they'll still have the old value. Also, users that haven't edited their profile since you added that field will have a blank value for that profile field, even if you specified a default, so you'll have to account for that somehow (I suppose you could make a class named "ghosthax-" that's the same as ghosthax-default).
Yes sorry, stupid mistake by me. I couldn't thank you you enough. You've been amazing help.
Thankyou.
--------------- Added 1331196951 at 1331196951 ---------------
New Problem;
http://screensnapr.com/e/jyxCXC.jpg
http://screensnapr.com/e/O6zcvZ.jpg
Results in the following;
http://screensnapr.com/e/535iYZ.jpg
The value in the {vb:raw post.field21} doesn't seem to be entered into the template in DB Tech templates.
http://screensnapr.com/e/EtHyuO.jpg
Any ideas?
We can't help with mod-related problems in this forum, you'd have to ask in the mod thread.
It could be that $post isn't registered in their template, but you'd have to look at the code to see.
Brexen
03-08-2012, 06:15 PM
We can't help with mod-related problems in this forum, you'd have to ask in the mod thread.
It could be that $post isn't registered in their template, but you'd have to look at the code to see.
I've never done anything like this before. What steps do I have to do to check it's registered and if it's not, how would I register $post in that template?
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.