Brad Sawatzky Posted October 2, 2012 Share Posted October 2, 2012 I'm building a business card template that uses graphic resources as phone labels, and I'm running into some trouble. The labels for phone 1 and phone 2 remain constant (phone, fax), but I need my phone 3 label to either return a cell graphic or an email graphic. My phone4 label will only return a value (email) if both phone 3 and 4 are populated. I think what I need is a hide graphic phone label rule, but this is my first crack at using variable graphics, and I could very well be wrong. I've tried to attach my zip file (8.7 MB), but run into a message that reads: "Your submission could not be processed because a security token was missing." Any help would be appreciated. Thanks, Quote Link to comment Share on other sites More sharing options...
step Posted October 2, 2012 Share Posted October 2, 2012 Try this: return (Field("Phone3") != "" && Field("Phone4") != "") ? Resource("Email Graphic") : Resource("Cell Graphic"); Quote Link to comment Share on other sites More sharing options...
Brad Sawatzky Posted October 3, 2012 Author Share Posted October 3, 2012 Thanks for the hand Ste, but variable graphics are a new world to me, and I'm still a bit confused. I wish I could load the zip file to explain myself a bit better, but I can attach a jpg to give you an idea of what the template looks like. I've left my phone1 & 2 labels as static, seeing as they won't change, and created seperate graphic frames for phone3 & 4 labels. Cell numbers are optional, and emails are manditory. In the case of no cell number, email has to justify to the left. A bit unconventional, but I couldn't think of another way of setting it up. I've set up a switch statement to handle phone3 label that looks like this: switch (Field("Phone3 Label").toLowerCase()) { case "Cell".toLowerCase(): return Resource("Cell Label"); case "Email".toLowerCase(): return Resource("Email Label"); default: return Resource("Cell Label"); } which works great if my phone3 is a cell number, but not so well if it's an email address. In defining the html form, I've made phone3 label a graphic pick list, and I'm not sure if this is where the problem lies. Sorry if it's a bit drawn out, but I hope this illustrates my problem better. Thanks again for the hand, Quote Link to comment Share on other sites More sharing options...
jwhittaker Posted October 3, 2012 Share Posted October 3, 2012 Brad Have you thought of creating separate pages for each of your versions? p1 having all fields (page name is "all") p2 having only the cell on the second line (page name is "cell") p3 having only the email on the second line (page name is "email") p4 having only 1 line of numbers (page name is "2numbers") You can then use a OnRecordStart Callback rule to "turn on" the page you want. You would have to go to page usage and name your pages and then click the unused check box to make them unused. Create a OnRecordStart Callback rule if ((Field("phone") != "") && (Field("fax") != "") && (Field("cell") != "") && (Field("email") != "")) FusionPro.Composition.SetBodyPageUsage("all", true); else if ((Field("phone") != "") && (Field("fax") != "") && (Field("cell") != "")) FusionPro.Composition.SetBodyPageUsage("cell", true); else if ((Field("phone") != "") && (Field("fax") != "") && (Field("email") != "") FusionPro.Composition.SetBodyPageUsage("email", true); else FusionPro.Composition.SetBodyPageUsage("2numbers", true); If your field denoting which version to use is called "Version" and the contents for each record are "1", "2", and "3", you would need to go into Page Usage in the FusionPro menu and set your 3 back template pages to "UNused" and give them names "1", "2", and "3". You would then set code in an OnRecordStart callback rule as follows: Code: FusionPro.Composition.SetBodyPageUsage(Field("Version"), true); This should handle your scenario of choosing the correct back for each record. The key is to make sure the name of your optional template pages is the same as the content in the field that indicate which one to use. Quote Link to comment Share on other sites More sharing options...
step Posted October 3, 2012 Share Posted October 3, 2012 It sounds like you want to use an inline graphic. I would create a text box and place it below the two mandatory numbers and set the contents of that text box to this rule: return (Field("Cell") != "") ? '<graphic file="Cell Label.jpg" height=1000>' + Field("Cell") + '<graphic file="Email Label.jpg" height=1000>'+ Field("email") : '<graphic file="Email Label.jpg" height=1000>' + Field("email") ; Basically, it's an if/then statement that will check to see if your "Cell" field is populated. If it is, then it returns a Cell label followed by a cell number, an email label, and the email address. If it's not, then it just returns an email label and the email address. Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted October 3, 2012 Share Posted October 3, 2012 It sounds like you want to use an inline graphic. I would create a text box and place it below the two mandatory numbers and set the contents of that text box to this rule: return (Field("Cell") != "") ? '<graphic file="Cell Label.jpg" height=1000>' + Field("Cell") + '<graphic file="Email Label.jpg" height=1000>'+ Field("email") : '<graphic file="Email Label.jpg" height=1000>' + Field("email") ; Basically, it's an if/then statement that will check to see if your "Cell" field is populated. If it is, then it returns a Cell label followed by a cell number, an email label, and the email address. If it's not, then it just returns an email label and the email address. Yes, inline graphics are a good way to do it, all in a single text frame, although this logic seems a bit cleaner to me: var cellPart = ""; if (Field("Cell")) cellPart = '<graphic file="Cell Label.jpg" height=1000>' + Field("Cell") + "<t>"; return cellPart + '<graphic file="Email Label.jpg" height=1000>' + Field("email");Note the tab tag after the cell number to set the next label in the proper position. That said, the picture suggests that all of this, including the first two phone number fields, is an excellent candidate for a table, also containing inline graphics in the first and third columns. Another option is to create a Repeatable Component (Template page) with a graphic frame and a text frame, and call it out either three or four times. Of course, you could just have separate rules for each of the graphic and text frames, but then the logic is in multiple places. If you want to use graphic frames to scale the graphics but still keep all of the logic together, what you can do is name each of the frames, and then inject the contents into them in OnRecordStart, like so: if (Field("Cell")) { FindGraphicFrame("Label 3").SetGraphic(Resource("Cell Label")); FindTextFrame("Text 3").content = Field("Cell"); FindGraphicFrame("Label 4").SetGraphic(Resource("Email Label")); FindTextFrame("Text 4").content = Field("Email"); } else { FindGraphicFrame("Label 3").SetGraphic(Resource("Email Label")); FindTextFrame("Text 3").content = Field("Email"); }Lots of ways to skin this cat. Quote Link to comment Share on other sites More sharing options...
Brad Sawatzky Posted October 22, 2012 Author Share Posted October 22, 2012 Skinned quite a few cats in different ways and got the result I was looking for. Appreciate all the help! Quote Link to comment Share on other sites More sharing options...
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.