Go Back   MarcomCentral (PTI) and FusionPro User Communities > Software-Related Talk > The JavaScript Library > Formatting Text

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old August 22nd, 2008, 08:25 AM
Admin's Avatar
Admin Admin is offline
Administrator
 
Join Date: Oct 2007
Posts: 331
Default Applying a Specific Color to a Variable

// This rule allows you to apply a color to a variable.

// There are three methods of specifying a color – using the color's name from the color dictionary, using the RGB value, using the CMYK value.
// Both the RGB and CMYK declarations use the Hexadecimal values.

// In the code, all three methods are listed. Simply remoev the methods you don't want and apply the correct value.
// For example, to apply "blue", <color name = "Blue">, <color RGB = "0000FF">, or <color CMYK = "FFE61900">

// The final line resets the color back to "black"


if (Field("fax") == "")
return "";

else
return "Fax: "+ "<color name = \"Blue\"> <color RGB = \"0000FF\"> <color CMYK = \"FFE61900\">" + Field("fax") + "<color name= \"Black\">";
__________________
Forum Administrator
PTI Marketing Technologies, Inc.
Reply With Quote
  #2  
Old September 30th, 2008, 02:51 PM
gabrielleb gabrielleb is offline
Forum n00b
 
Join Date: Sep 2008
Location: Phoenix, AZ
Posts: 5
Default Re: Applying a Specific Color to a Variable

I have a business card template that contains several fields (Name, Title, Slogan, Phone1label, Phone1, etc). I also have several rules in the template. I want to make all of the text blue if Blue is chosen from a dropdown list, or all the text Red if Red is chosen from the dropdown list, otherwise all needs to remain black. Do I need to write a rule for each field, or is there a rule i can write to effect all active fields?

gabrielle
gabrielleb@harrisprinters.com
Reply With Quote
  #3  
Old October 1st, 2008, 02:19 PM
jshobar jshobar is offline
Regular Contributor
 
Join Date: Sep 2008
Location: San Diego
Posts: 80
Default Re: Applying a Specific Color to a Variable

Gabrielle-

Use the above rule, but instead of Calling the color out like: <color name = \"Blue\">,
call it out as a variable as such : <color name = CardColor>

Then write a rule to assign Red or Black to CardColor: if .... then CardColor = "Red", else CardColor = "Black"
Reply With Quote
  #4  
Old October 1st, 2008, 03:57 PM
gabrielleb gabrielleb is offline
Forum n00b
 
Join Date: Sep 2008
Location: Phoenix, AZ
Posts: 5
Default Re: Applying a Specific Color to a Variable

Thank you jshobar:
I understand where you are going with this, but i am still unclear how to fully implement this to all of the fields without writing a separate rule for each field.
Is there a script to change all the variable fields to the ColorCard color?
__________________
gabrielle becker
gabrielleb@harrisprinters.com
Reply With Quote
  #5  
Old October 1st, 2008, 04:13 PM
jshobar jshobar is offline
Regular Contributor
 
Join Date: Sep 2008
Location: San Diego
Posts: 80
Default Re: Applying a Specific Color to a Variable

Not that I can think off off hand. Even with alot of Fields, you only have to write one rule and duplicate it a number of times, changing one line. Or if you can set all your text as a Resource, you could then grab the tagged text and have one rule that would change the entire color of the resource. Alternatively, there may be code you could write that would redefine the color "Black" to be what ever you wanted it to be, but I'm not sure on that one.
Reply With Quote
  #6  
Old October 1st, 2008, 04:32 PM
mhilger's Avatar
mhilger mhilger is offline
Senior Contributor
 
Join Date: Aug 2008
Location: Chicago
Posts: 326
Default Re: Applying a Specific Color to a Variable

Hello Gabrielle,

I tried a couple of things and think there might be an easier way to accomplish what you are after with 1 rule.

Make a rule called something like colorChangeRule that looks like this:

Code:
return '<color name="' + Field("Color") + '">';
Make sure you select the "treat returned strings as tagged text" option in your rule. This rule assumes you have a field called "Color" that references a valid color in your template.

Then, in the variable text editor where you want the color to be used for your data, just insert this rule "colorChangeRule" before any placement of your fields. for example:

«colorRule»«First Name» «Last Name»
«colorRule»«Address 1»

This rule should change the color of the text after it. Notice, though, that if you have a new line, you need to place that rule again.

Is this what you are looking for?
__________________
--Mark Hilger
Reply With Quote
  #7  
Old October 1st, 2008, 04:46 PM
jshobar jshobar is offline
Regular Contributor
 
Join Date: Sep 2008
Location: San Diego
Posts: 80
Default Re: Applying a Specific Color to a Variable

Great Solution!

If you didn't want to Include the color in the data you could change the above to:

Code:
 return '<color name="' + Rule("Color") + '">';
And then have one Rule that decides the color.

Last edited by jshobar; October 1st, 2008 at 04:50 PM..
Reply With Quote
  #8  
Old October 2nd, 2008, 11:06 AM
gabrielleb gabrielleb is offline
Forum n00b
 
Join Date: Sep 2008
Location: Phoenix, AZ
Posts: 5
Thumbs up Re: Applying a Specific Color to a Variable

Wow you guys!! Thank you soo much for your help. I will give it go, and now, finally, I get to rightfully use one of the smiley icons!!
__________________
gabrielle becker
gabrielleb@harrisprinters.com
Reply With Quote
  #9  
Old October 2nd, 2008, 02:16 PM
gabrielleb gabrielleb is offline
Forum n00b
 
Join Date: Sep 2008
Location: Phoenix, AZ
Posts: 5
Default Re: Applying a Specific Color to a Variable

This worked GREAT! Now I can do the same sort of thing with Font choice too!
Thank you again!
__________________
gabrielle becker
gabrielleb@harrisprinters.com
Reply With Quote
  #10  
Old October 2nd, 2008, 02:41 PM
mhilger's Avatar
mhilger mhilger is offline
Senior Contributor
 
Join Date: Aug 2008
Location: Chicago
Posts: 326
Default Re: Applying a Specific Color to a Variable

Good to hear this works for you, Gabrielle.

As you point out, you can indeed use this method to have rules enable a number of other character/paragraph formatting options as well such as font name, bold, italic, font size, alignment, etc.
__________________
--Mark Hilger
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 07:07 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) 2011, PTI Marketing Technologies™, Inc.