Jump to content

Insert Picture rule


Maria

Recommended Posts

I am running FP 7.1 on a PC. We have developed our own customer interface and we are using FP server.

 

I am working on a greeting card project. In the customer interface the customer will be able to upload their own image. I want to be able to have an FPO image viewing when they first access their proof. If they upload an image, I want FP to drop the FPO and view the upload. If they do not upload an image I want the FPO to drop out.

 

Basically, A is the FPO, B is the upload, and C is null.

 

I need a rule that will do this: Show A as a default image. If B is present show B. If B is not present show C.

 

Is this possible using rules in FP desktop?

Link to comment
Share on other sites

Good morning Maria,

 

First of all...how many times are you going to be calling FusionPro to make a proof? It sounds like only one, but I'm not quite sure from your description. We also use our own websites and our own customized programming for it. When we set up a flyer for our customers we give them a static, generic image of an entire flyer already build up and filled in with sample data and highlighted with what we call "call outs" - descriptive pointers that define all the customizable areas. It would be in that static image that I would place your "FPO" image along with the words "For Placement Only" in a transparent stamp or watermark on top or a better choice would be the words "Your Personalized Image Here". This image would not change and would show up in the area where the customers enter their data.

 

In the Template I would use a rule such as

if (Trim(Field("imageUpload")) != "")  {
  var r = new FusionProResource(Field("imageUpload"), "graphic", true);
  if (r.exists)  {
     return r;
  }
  else  {
     return Resource("errorFile");
  }
}
else  {
  NullResource();
}

What this will do is create a new resource on the fly based on the contents of the field "imageUpload" when that field is not blank. I've also created an error-checking step in there to test whether or not the image was uploaded correctly or not. By adding the statement "if (r.exists)" I first check to see if the file that was requested was actually uploaded correctly by checking to see if it actually exists in the location it is supposed to be in. If it does exist then display the image in the flyer. If it does not, then I would display a solid red image with the wording "problem with file upload" in bold white letters in the area where the graphic is supposed to be on the flyer. Finally if the field "imageUpload" is blank then I would pass the NullResource() statement to simply leave it blank.

 

Hope this helps.

.

Link to comment
Share on other sites

  • 1 month later...

I am having a problem with a rule similar to this. I need to create a resource based off an agent_number field and insert the picture if it exists. If not, then I need to use a resource named 'phone'. This is what my rule looks like right now

 

if (Field("Agent_Number")!= "NULL")
var Pic = new FusionProResource(Field("Agent_Number") + ".jpg", "graphic");
if (Pic.exists) {
   return Pic;
}
else
   {
   return Resource("Phone") += ReportWarning("Image for " + Field("Agent_Number") + " " + Field("Agent") + " not found");
   }

 

This works great for inserting the picture when it exists, however, it doesn't use the phone logo when the agent picture is not available.

 

Any thoughts?

 

Thanks,

Jeff

Link to comment
Share on other sites

I'm not sure what the += in the last line is supposed to do. Also, you need to specify the third parameter (nonExistOK) to FusionProResource/CreateResource. Try this:

var Pic = new FusionProResource(Field("Agent_Number") + ".jpg", "graphic", true);
if (Pic.exists)
   return Pic;

ReportWarning("Image for " + Field("Agent_Number") + " " + Field("Agent") + " not found");
return Resource("Phone");

Link to comment
Share on other sites

That worked great! The += was accidental. I was trying to use the + operator the wrong way. I was having trouble figuring out how to ask it to do two things if the agent picture was not available.

 

Thanks for your help Dan. As always, it is very much appreciated :)

Link to comment
Share on other sites

That worked great! The += was accidental. I was trying to use the + operator the wrong way. I was having trouble figuring out how to ask it to do two things if the agent picture was not available.

The way to "ask it to do two things" is to simply have two separate statements, either on separate lines, or delimited with a semicolon (";"). The + and += operators are used for arithmetic and for string concatenation, not to join separate statements. Also, remember that nothing else happens after you return.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...