Go Back   PTI Marketing Technologies User Community > Software-Related Talk > The JavaScript Library > Graphic Rules

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old June 3rd, 2015, 09:44 AM
mmorse mmorse is offline
Junior Community Member
 
Join Date: May 2015
Posts: 18
Default return unique images within a switch case rule

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
Reply With Quote
  #2  
Old June 3rd, 2015, 10:32 AM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 3,980
Default Re: return unique images within a switch case rule

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.
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral
LinkedIn

I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@pti.com.

Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@PTI.com. Paid consulting work may be required to fulfill your template-building needs. Please do not post proprietary font files to this forum.

Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages.

Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance.

Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support.

How To Ask Questions The Smart Way

The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript.

Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5.

return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)});
Reply With Quote
  #3  
Old June 3rd, 2015, 10:35 AM
mmorse mmorse is offline
Junior Community Member
 
Join Date: May 2015
Posts: 18
Default Re: return unique images within a switch case rule

Thanks Dan -

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

Thank you!
Reply With Quote
  #4  
Old June 3rd, 2015, 11:11 AM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 3,980
Default Re: return unique images within a switch case rule

Quote:
Originally Posted by mmorse View Post
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:
Code:
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".
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral
LinkedIn

I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@pti.com.

Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@PTI.com. Paid consulting work may be required to fulfill your template-building needs. Please do not post proprietary font files to this forum.

Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages.

Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance.

Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support.

How To Ask Questions The Smart Way

The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript.

Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5.

return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)});
Reply With Quote
  #5  
Old June 3rd, 2015, 03:22 PM
mmorse mmorse is offline
Junior Community Member
 
Join Date: May 2015
Posts: 18
Default Re: return unique images within a switch case rule

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];
Reply With Quote
  #6  
Old June 3rd, 2015, 03:47 PM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 3,980
Default Re: return unique images within a switch case rule

Quote:
Originally Posted by mmorse View Post
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.
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral
LinkedIn

I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@pti.com.

Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@PTI.com. Paid consulting work may be required to fulfill your template-building needs. Please do not post proprietary font files to this forum.

Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages.

Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance.

Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support.

How To Ask Questions The Smart Way

The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript.

Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5.

return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)});
Reply With Quote
  #7  
Old June 4th, 2015, 01:16 PM
mmorse mmorse is offline
Junior Community Member
 
Join Date: May 2015
Posts: 18
Default Re: return unique images within a switch case rule

Hey Dan...

I got it working, thanks so much for the help.
Reply With Quote
  #8  
Old February 8th, 2016, 09:17 PM
Al N. Al N. is offline
Forum n00b
 
Join Date: Apr 2015
Posts: 2
Default Re: return unique images within a switch case rule

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?
Reply With Quote
  #9  
Old February 8th, 2016, 09:18 PM
Al N. Al N. is offline
Forum n00b
 
Join Date: Apr 2015
Posts: 2
Default Re: return unique images within a switch case rule

I also have not been in the forum in some time and its different and having trouble navigating the site.
Reply With Quote
  #10  
Old February 9th, 2016, 10:55 AM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 3,980
Default Re: return unique images within a switch case rule

Quote:
Originally Posted by Al N. View Post
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.
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral
LinkedIn

I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@pti.com.

Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@PTI.com. Paid consulting work may be required to fulfill your template-building needs. Please do not post proprietary font files to this forum.

Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages.

Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance.

Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support.

How To Ask Questions The Smart Way

The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript.

Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5.

return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)});
Reply With Quote
Reply

Tags
image rule, javascript, switch case

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 02:29 PM.


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