Jump to content

Callout Pages based on multiple entries


rpaterick

Recommended Posts

Need help in modifying the following code that is high-lighted in red:

I'm not sure on how you do multiple data inputs for page switch/callout.

 

 

if (Field("Master Tier") == "[color=Red]Platinum Y Freedom","Platinum N Platinum[/color]")
{
   FusionPro.Composition.SetBodyPageUsage("2",true);
   FusionPro.Composition.SetBodyPageUsage("3",true);
}
else
{
   FusionPro.Composition.SetBodyPageUsage("1",true);
   FusionPro.Composition.SetBodyPageUsage("3",true);
}

 

 

Thanks!

Link to comment
Share on other sites

There are several things you can do. The simplest is probably just to change the first line like so:

if (Field("Master Tier") == "Platinum Y Freedom" || Field("Master Tier") == "Platinum N Platinum")

Or, better yet, especially if there are a lot of possibilities to match, you can use a switch statement, like so:

switch (Field("Master Tier"))
{
   case "Platinum Y Freedom":
   case "Platinum N Freedom":
       FusionPro.Composition.SetBodyPageUsage("2",true);
       FusionPro.Composition.SetBodyPageUsage("3",true);
       break;

   default:
       FusionPro.Composition.SetBodyPageUsage("1",true);
       FusionPro.Composition.SetBodyPageUsage("4",true);
}

Or, depending on what other values are in the data, instead of matching full strings, you might be able to do pattern-matching instead; something like this for the first line:

if (Field("Master Tier").match(/Platinum [YN] Freedom/))

Or, more generally:

if (Field("Master Tier").match(/Platinum . Freedom/))

Or, even more generally:

if (Left(Field("Master Tier"), 8) == "Platinum")

Link to comment
Share on other sites

switch (Field("Master Tier"))
{
   case "Platinum Y Freedom":
   case "Platinum N Freedom":
       FusionPro.Composition.SetBodyPageUsage("2",true);
       FusionPro.Composition.SetBodyPageUsage("3",true);
       break;

   default:
       FusionPro.Composition.SetBodyPageUsage("1",true);
       FusionPro.Composition.SetBodyPageUsage("4",true);
}

 

Thanks Dan! I was trying to figure out how to cleanup the code and this did it!

 

I have another question and it's not topic related here:

Would you be able to direct me to a thread that deals with changing font color based on data input as well? Or is there something in the user manual that explains how to do this?

 

Thanks Dan for your help!

Link to comment
Share on other sites

I have another question and it's not topic related here:

Would you be able to direct me to a thread that deals with changing font color based on data input as well? Or is there something in the user manual that explains how to do this?

Sure, take a look at this thread:

http://forums.pti.com/showthread.php?t=27

 

I found it with this search:

https://google.com/search?q=site:forums.pti.com+font+color+based+on+data

Link to comment
Share on other sites

 

 

Thanks Dan.

 

I'm trying to put it together now.

 

Code for color:

 

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

else
return "CardImage: "+ "<color name = \"White\"> " + Field("CardImage") + "<color name= \"Black\">";

 

Code to change the Full Name field to ALL CAPS.

 

var Var1 = "Full Name";
var CaseSelection = "allcaps";



if(CaseSelection == "allcaps")
   return ToUpper(Field(Var1));

if(CaseSelection == "smallcaps")
   return "<smallcap>" + Field(Var1) + "</smallcap>";

if(CaseSelection == "propercase")
   return ToTitleCase(Field(Var1));

if(CaseSelection == "lowercase")
   return ToLower(Field(Var1));


 

Put it together

 

return '<ColorRule="' + Rule("Full Name On Card") + '">';

 

 

I'm close but can't seem to get it to work. I might not be close either...:o

Link to comment
Share on other sites

Thanks Dan.

 

I'm trying to put it together now.

 

Code for color:

 

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

else
return "CardImage: "+ "<color name = \"White\"> " + Field("CardImage") + "<color name= \"Black\">";

Code to change the Full Name field to ALL CAPS.

 

var Var1 = "Full Name";
var CaseSelection = "allcaps";



if(CaseSelection == "allcaps")
   return ToUpper(Field(Var1));

if(CaseSelection == "smallcaps")
   return "<smallcap>" + Field(Var1) + "</smallcap>";

if(CaseSelection == "propercase")
   return ToTitleCase(Field(Var1));

if(CaseSelection == "lowercase")
   return ToLower(Field(Var1));


Put it together

 

return '<ColorRule="' + Rule("Full Name On Card") + '">';

I'm close but can't seem to get it to work. I might not be close either...:o

Well, I expected that you would post follow-ups about this color issue to the other thread, where it's more relevant. But okay.

 

I don't know what you mean by "put it together." I at least need to know what the names of the rules are in order to combine them. I assume that your first block of code is a rule name "ColorRule", and that your second block is a rule named "Full Name On Card".

 

Also, I don't know that field you're trying to apply these rules to. The first rule calls out a field named "CardImage", while the second calls out a rule named "Full Name".

 

So what are you really trying to do here? Are you trying to set the "CardImage" field, or the "Full Name" field? Or both, and if so, how are these rules related at all?

 

Anyway, the "Full Name On Card" rule can be reduced to this:

return ToUpper(Field("Full Name"));

 

Now, if what you're really trying to do is set that field value, capitalized, in a specific color, you don't need a JavaScript rule at all. Just call out the rule in a text frame, and set the color there in the Text Editor.

 

If you want to put a label (like "CardImage: ") in front of the field value, which only shows if the field value itself is not empty, then just type that label into the Text Editor as well, then click Paragraph, check the "Suppress if" box, and select "Containing Empty Variables" from the drop-down list.

Link to comment
Share on other sites

Also, I don't know that field you're trying to apply these rules to. The first rule calls out a field named "CardImage", while the second calls out a rule named "Full Name".

 

So what are you really trying to do here? Are you trying to set the "CardImage" field, or the "Full Name" field? Or both, and if so, how are these rules related at all?

 

Sorry Dan about the confusion.

 

Here is a breakdown:

Field Full Namein Data file needs to be capitalized, right now it's initial caps.

The rule "Full Name On Card" is the ALL Caps rule that's needed.

 

Whenever the name FREEDOM appears in the CardImage field, I need the font color to change to Full Name On Card. ColorRule should be then applied.

 

So I'm trying to combine Full Name on Card and the CardImage Rules together to get the desired outcome, one rule.

 

Thanks Dan, appreciate the help.

Link to comment
Share on other sites

Here is a breakdown:

Field Full Namein Data file needs to be capitalized, right now it's initial caps.

The rule "Full Name On Card" is the ALL Caps rule that's needed.

 

Whenever the name FREEDOM appears in the CardImage field, I need the font color to change to Full Name On Card. ColorRule should be then applied.

I'm still confused by this:

 

  • What do you mean by "I need the font color to change to Full Name On Card"? You want the color to change to the name?
  • This is the first I've heard you mention "FREEDOM". Where is that in your rules so far?
  • What happened to the static text "CardImage: " in your first rule? Where does that fit into all of this?

So I'm trying to combine Full Name on Card and the CardImage Rules together to get the desired outcome, one rule.

I'm still not sure I understand exactly, but this might work:

var colorTag = (Field("CardImage") == "FREEDOM") ? '<color name="White">' : "";
return colorTag + TaggedTextFromRaw(ToUpper(Field("Full Name"))) + (colorTag ? '</color>' : "");

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...