mmorse Posted June 3, 2015 Posted June 3, 2015 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 Quote
Dan Korn Posted June 3, 2015 Posted June 3, 2015 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. Quote
mmorse Posted June 3, 2015 Author Posted June 3, 2015 Thanks Dan - Could you elaborate on what exactly the would look like, and how it would correspond with the already existing rule? Thank you! Quote
Dan Korn Posted June 3, 2015 Posted June 3, 2015 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". Quote
mmorse Posted June 3, 2015 Author Posted June 3, 2015 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]; Quote
Dan Korn Posted June 3, 2015 Posted June 3, 2015 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. Quote
mmorse Posted June 4, 2015 Author Posted June 4, 2015 Hey Dan... I got it working, thanks so much for the help. Quote
Al N. Posted February 9, 2016 Posted February 9, 2016 I have a 2 page 6x11 postcard. I have a main page with variable images and text but I also have insert 12 body pages to switch to but my rule has a syntax error at the end. I'm stumped. Can anyone help me? Quote
Al N. Posted February 9, 2016 Posted February 9, 2016 I also have not been in the forum in some time and its different and having trouble navigating the site. Quote
Dan Korn Posted February 9, 2016 Posted February 9, 2016 my rule has a syntax error at the end. I'm stumped. Can anyone help me? Can you post the rule? Also, please feel free to start a new thread. Quote
Recommended Posts
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.