Jump to content

Image Drop-Down Menu in Marcom Central


LesSjo

Recommended Posts

I am attempting to use an image drop-down menu. I have used them in numerous other templates, but in this case I am not able to get the image to show in the online proof. What gets me is that I can compose the proof at my desktop just fine.

 

Here is the rule I am using for the logo. It just a basic graphic switch rule.

 

switch (Field("Logo"))
{
   case "AppraisalEnv":
       return Resource("AppraisalEnv");
   case "BankAndTrustEnv":
       return Resource("BankAndTrustEnv");
   case "FinancialFDICEnv":
       return Resource("FinancialFDICEnv");
   case "RetirementEnv":
       return Resource("RetirementEnv");
   case "InsuranceEnv":
       return Resource("InsuranceEnv");
   case "FinancialNoFDICEnv":
       return Resource("FinancialNoFDICEnv");
   case "InvestmentEnv":
       return Resource("InvestmentEnv");
   case "PropertyEnv":
       return Resource("PropertyEnv");
   case "SecuritiesEnv":
       return Resource("SecuritiesEnv");
   case "MortgageEnv":
       return Resource("MortgageEnv");
   default:
       return NullResource();
}�

The resources are named as in the rule, and I have uploaded the images in the online library and linked them to the drop-down menu.

 

A preview shows no images.

 

Anybody?

Link to comment
Share on other sites

It looks you have built a graphic switch rule which returns a resource based on the selection of a graphic image. Although this works on the desktop, this WILL NOT WORK once uploaded to the manager.

 

The reason for this is because once uploaded to an image library, the value in a graphic field is no longer just the image name itself (such as "DOG.pdf"), it will be the PATH to the image (such as "\\xxxxx.printable.com\isrepository\Libraries\12345\BackgroundColor\images\src\DOG.pdf"). So if a switch rule is going to return something when "DOG.pdf" is selected, the rule will not return anything because the library path does not match "DOG.pdf."

 

WORKAROUNDS:

There are several workarounds for this

1. if the user does not need to BROWSE for the image, then they can use a text dropdown for your switch rule conditions instead.

2. there is a function called MATCH PATH TO STRING which can be placed in the globals, which looks for the string inside the path. In our example it looks to see if the string "\\xxxxx.san.printable.com\isrepository\Libraries\12345\BackgroundColor\images\src\DOG.pdf" contains "DOG.pdf" . We can provide this to you if you need it. Eventually this function will be added into the rules editor.

3. if you have just written a switch rule that returns the resource "DOG.pdf" if "DOG.pdf" is selected, then you can delete your switch rule and just assign the graphic field to the graphic copyhole instead.

Link to comment
Share on other sites

WORKAROUNDS:

2. there is a function called MATCH PATH TO STRING which can be placed in the globals, which looks for the string inside the path. In our example it looks to see if the string "\\xxxxx.san.printable.com\isrepository\Libraries\12345\BackgroundColor\images\src\DOG.pdf" contains "DOG.pdf" . We can provide this to you if you need it..

 

If you could supply me with the string for this, I would greatly appreciate it.

 

Thanks,

Link to comment
Share on other sites

I don't think you need any kind of special function here. The best part of Stella's advice is this:

3. if you have just written a switch rule that returns the resource "DOG.pdf" if "DOG.pdf" is selected, then you can delete your switch rule and just assign the graphic field to the graphic copyhole instead.

Specifically, it seems to me that you can reduce the entire rule to this single line:

return Resource(Field("Logo"));

Link to comment
Share on other sites

Sorry, my last post was incomplete. Under MarcomCentral, with a Graphic field, you do still need to match just the file name of the graphic, rather than the full path.

 

If the names of the actual graphic files uploaded to MarcomCentral do not have filename extensions (e.g. "AppraisalEnv", "BankAndTrustEnv", etc., rather than "AppraisalEnv.jpg"), then you can use the logic in this post. In this case:

function FileNameFromPath(fullPath)
{
 return String(fullPath).replace(/^.*(\\|\/|\:)/, '');
}

return Resource(FileNameFromPath(Field("Logo")));

If the graphic files contain extensions ("AppraisalEnv.jpg" etc.), then you'll need to use this slightly different logic:

function FileNameFromPath(fullPath)
{
 return String(fullPath).replace(/^.*(\\|\/|\:)/, '');
}

function RemoveFileExtension(filename)
{
 return String(filename).replace(/\.[^\.]*$/, '');
}

return Resource(RemoveFileExtension(FileNameFromPath(Field("Logo")), ''));

Note that because of the way MarcomCentral writes the data file, with the full path to each graphic file, it's difficult to test this solution in FP Desktop.

Edited by Dan Korn
Added RemoveFileExtension (ReplaceFileExtension keeps the dot)
Link to comment
Share on other sites

Sorry for yet another follow-up, but after thinking about this a little more, it seems simpler and more reliable to just use the full path of the actual graphic file in a CreateResource call, like so:

return CreateResource(Field("Logo"));

This will guarantee that the exact graphic file corresponding to the selection in the image drop-down menu in MarcomCentral will be used in the output. You don't even need to add any Resources to the job at all.

 

This will work under FP Desktop as well, as long as you put the actual filenames (with extensions) in your input data file. Also for Desktop, if the graphic files are not in the same folder as the PDF template, you can either write the full paths to the data file, or you can set the Search Path in the Composition Settings dialog, Advanced tab.

Edited by Dan Korn
Link to comment
Share on other sites

  • 1 year later...

I have a similar problem but not quite the same.

 

I would like the user to be able to upload an image and have that image appear in one or more placeholders depending on the text in a drop down box.

 

Basically I want the user to be able to upload an image, the text in image position contains "front' then the image should appear in the 'front' graphic box, if it contains 'back' then it should also appear in the 'back' graphic box.

These rules work fine in Desktop but not in Marcom Central. I understand that I can point the resource to the library path but what would the path be if the user uploads the image?

Link to comment
Share on other sites

  • 1 year later...
×
×
  • Create New...