Jump to content

return unique images within a switch case rule


mmorse

Recommended Posts

Hello All -

 

I recently posted a question about changing font colors when a certain image is selected, and was given this rule as a solution, and it works perfectly.

 

var color = '';

switch (GetFileName(Field("headerImage"))){

case "red.pdf":

color = "PANTONE Red 032 C";

break;

case "blue.pdf":

color = "PANTONE 2945 C";

break;

case "gray.pdf":

color = "PANTONE 430 C";

break;

default:

color = "PANTONE 266 C";

}

return '<color name="' + color + '">' + ToUpper(Field("dynamicSubOne")) + '</color>';

 

 

 

Since then, there was a request for additional functionality. Now ,in addition to the above, I need to return a unique image as well to a picframe ("logo") that is also associated with the color themes. I've made a number of attempts, but I'm not able to get the actual image to change. Any advice on how to associate a unique pic within the switch case rule?

 

Any help very much appreciated!

Matt

Link to comment
Share on other sites

You need a separate Graphic rule.

 

Actually, in OnRecordStart, you could combine the logic to set the text in the text frame and the graphic in the graphic frame with some calls to FindTextFrame and FindGraphicFrame, or with calls to FusionPro.Composition.AddVariable and FusionPro.Composition.AddGraphicVariable, but since you already have the text rule working, it's more straightforward to just make a separate graphic rule.

Link to comment
Share on other sites

Could you elaborate on what exactly the would look like, and how it would correspond with the already existing rule?

 

I imagine the graphic rule would look something like this:

switch (GetFileName(Field("headerImage")))
{
case "red.pdf":
   return Resource("RedLogo");
case "blue.pdf":
   return Resource("BlueLogo");
case "gray.pdf":
   return Resource("GrayLogo");
default:
   return Resource("DefaultLogo");
}

Although you could also accomplish this with a Graphic Switch Wizard rule, with "Compare As" set to "File Name".

Link to comment
Share on other sites

Ok...So this is where I'm at.. instead of the image populating the "logo" filed, it produces the file name in text within the "dynnamicSubOne" field. How do I write this so that the image within another field is dynamically updated when a certain color is selected?

 

Any help much apprciated

 

Thanks!

 

var color = '';

switch (GetFileName(Field("headerImage"))){

case "red.pdf":

color = "PANTONE Red 032 C";

break;

case "blue.pdf":

color = "PANTONE 2945 C";

break;

case "gray.pdf":

color = "PANTONE 430 C";

break;

case "Teal.pdf":

color = "teal";

break;

default:

color = "PANTONE 266 C";

}

var subHead = '<color name="' + color + '">' + ToUpper(Field("dynamicSubOne")) + '</color>';

 

 

switch (GetFileName(Field("logo"))){

case color = "PANTONE 2945 C": /*blue*/

newLogo = Resource("physicianServices.eps");

break;

case color = "teal": /*teal*/

newLogo = Resource("pediatricAlliance.eps");

break;

case color = "PANTONE 266C": /*purple*/

newLogo = Resource("pediatricPartners.eps")

default:

newLogo = false;

 

}

 

return [newLogo,subHead];

Link to comment
Share on other sites

Ok...So this is where I'm at.. instead of the image populating the "logo" filed, it produces the file name in text within the "dynnamicSubOne" field. How do I write this so that the image within another field is dynamically updated when a certain color is selected?

Perhaps I wasn't clear. You need two different rules. Not one rule to handle both the text and the graphic. You need a text rule, for the text, and you also need a graphic rule, for the graphic. Two rules.

 

To create the Graphic rule, from the Rules dialog, click New, then under "Select Rule Type", click the "Graphic" button. Now you will be creating a graphic rule, which can be assigned to a graphic frame, as opposed to a text rule, which gets used in a text frame.

Link to comment
Share on other sites

  • 8 months later...

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...