MarcomCentral (PTI) and FusionPro User Communities

MarcomCentral (PTI) and FusionPro User Communities (http://forums.pti.com/index.php)
-   Formatting Text (http://forums.pti.com/forumdisplay.php?f=32)
-   -   Font Color & Weight Changes in FusionPro (http://forums.pti.com/showthread.php?t=5084)

traba5058 February 14th, 2018 01:02 PM

Font Color & Weight Changes in FusionPro
 
All,

I need help.

I have a customer that can add up to 2 phone numbers on a business card. The field tags vary.

They need to bold the two phone tag fields and change the color for the divider between the 2 numbers if both are used.

I have Treat as Tagged Text selected.

I have tried both <b></b> and <f name=""></f>

My rule current rule is
Code:

if (Field("Phone 1") != "" && Field("Phone 2") != "")
    return <f name="Gotham Bold">Field("Phone 1 Tag")</f>+' '+Rule("Rule_FormatPhone")+' '+<color name="c0m36y100k8">|</color>+' '+<f name="Gotham Bold">Field("Phone 2 Tag")</f>+' '+Rule("Rule_FormatPhone2");
else if (Field("Phone 1") != "" && Field("Phone 2") == "")
    return <f name="Gotham Bold">Field("Phone 1 Tag")</f>+' '+Rule("Rule_FormatPhone");
else if (Field("Phone 1") == "" && Field("Phone 2") != "")
    return <f name="Gotham Bold">Field("Phone 2 Tag")</f>+' '+Rule("Rule_FormatPhone2");
else if (Field("Phone 1") == "" && Field("Phone 2") == "")
    return "";

When I check fonts used under advanced, I see Gotham Book and Gotham Bold I also see this in the text frame.

The color name for the color I want to use is c0m36y100k8. I see this in both the text frame color drop down as well as colors under advanced.

My phone format rules are formatting the numbers as (000) 000-0000.

I'm not getting any errors on compose, but it is returning the following:

Field("Phone 1 Tag") (404) 213-8360 | Field("Phone 2 Tag") (404) 941-2631

The whole line is black and there is no bold.

I appreciate any of the help I can get.

Thanks,
Traba

traba5058 February 14th, 2018 01:35 PM

Re: Font Color & Weight Changes in FusionPro
 
All,

I updated my rule to
Code:

if (Field("Phone 1") != "" && Field("Phone 2") != "")
    return '<f name="Gotham Bold">Field("Phone 1 Tag")</f>'+' '+Rule("Rule_FormatPhone")+'  '+'<color name="c0m36y100k8">|</color>'+' '+'<f name="Gotham Bold">Field("Phone 2 Tag")</f>'+' '+Rule("Rule_FormatPhone2");
else if (Field("Phone 1") != "" && Field("Phone 2") == "")
    return '<f name="Gotham Bold">Field("Phone 1 Tag")</f>'+' '+Rule("Rule_FormatPhone");
else if (Field("Phone 1") == "" && Field("Phone 2") != "")
    return '<f name="Gotham Bold">Field("Phone 2 Tag")</f>'+' '+Rule("Rule_FormatPhone2");
else if (Field("Phone 1") == "" && Field("Phone 2") == "")
    return "";

And am getting the bold font & color changes. However, I've lost the space after the divider when 2 numbers are used and it is not showing the tag.

It's returning:
Field("Phone 1 Tag") (404) 213-8360 |Field("Phone 2 Tag") (404) 941-2631
with bold tags & yellow |. And missing the space between the | and phone 2 tag.

Any ideas?

Dan Korn February 14th, 2018 03:08 PM

Re: Font Color & Weight Changes in FusionPro
 
You need to be more careful with your quotes, so that the JavaScript engine knows what parts of your code are literal strings vs. function calls. You should be able to see what's being returned in the Rule Editor when you click Validate, without even composing, to see whether you're on the right track or not. And actually, even without clicking Validate, the syntax coloring in the Rule Editor should give you an idea of what's a literal string and what isn't. (You can click the Editor Settings button to change the Char Color and Strings Color settings to something with more contrast if that helps.)

This should work to keep the Field function calls from being output literally:
Code:

if (Field("Phone 1") != "" && Field("Phone 2") != "")
    return '<f name="Gotham Bold">' + Field("Phone 1 Tag") + '</f>'+' '+Rule("Rule_FormatPhone")+'  '+'<color name="c0m36y100k8">|</color>'+' '+'<f name="Gotham Bold">' + Field("Phone 2 Tag") + '</f>'+' '+Rule("Rule_FormatPhone2");
else if (Field("Phone 1") != "" && Field("Phone 2") == "")
    return '<f name="Gotham Bold">' + Field("Phone 1 Tag") + '</f>'+' '+Rule("Rule_FormatPhone");
else if (Field("Phone 1") == "" && Field("Phone 2") != "")
    return '<f name="Gotham Bold">' + Field("Phone 2 Tag") + '</f>'+' '+Rule("Rule_FormatPhone2");
else if (Field("Phone 1") == "" && Field("Phone 2") == "")
    return "";

Though you may also need to use entities or <space> tags in order to be able to output a space after a tag (such as </f>), so this should fix that:
Code:

if (Field("Phone 1") != "" && Field("Phone 2") != "")
    return '<f name="Gotham Bold">' + Field("Phone 1 Tag") + '</f><space>'+Rule("Rule_FormatPhone")+'  '+'<color name="c0m36y100k8">|</color><space>'+'<f name="Gotham Bold">' + Field("Phone 2 Tag") + '</f><space>'+Rule("Rule_FormatPhone2");
else if (Field("Phone 1") != "" && Field("Phone 2") == "")
    return '<f name="Gotham Bold">' + Field("Phone 1 Tag") + '</f><space>'+Rule("Rule_FormatPhone");
else if (Field("Phone 1") == "" && Field("Phone 2") != "")
    return '<f name="Gotham Bold">' + Field("Phone 2 Tag") + '</f><space>'+Rule("Rule_FormatPhone2");
else if (Field("Phone 1") == "" && Field("Phone 2") == "")
    return "";

I'll also note that there are several ways in which this code can be made simpler and more succinct. For instance:
Code:

var items = [];

if (Field("Phone 1"))
    items.push('<f name="Gotham Bold">' + Field("Phone 1 Tag") + '</f><space>' + Rule("Rule_FormatPhone"));

if (Field("Phone 2"))
    items.push('<f name="Gotham Bold">' + Field("Phone 2 Tag") + '</f><space>' + Rule("Rule_FormatPhone2"));

return items.join('  <color name="c0m36y100k8">|</color><space>');



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

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