Jump to content

Need rule to return graphic file and related formatted text resource


Kim

Recommended Posts

Hi all,

 

Trying to figure out best way to allow users to choose logos from a list to insert on a form (using Fusion Server/Windows). There will be 10 logo areas on the output, with 10 corresponding/related info areas.

 

The user will select a logo from a pulldown list for 10 different fields. If they choose Logo A, then the graphic file for Logo A will be shown in position 1 and the corresponding formatted text resource for Logo A should appear below Logo A.

 

I'm trying to figure out the best way to write the rules so that whatever logo they choose for position 1, they'll also get the text for the logo they chose.

 

Basically:

If (Field(Logo1)==ABC.jpg)

return Resource(ABC)

If (Field(Logo1)==XYZ.jpg)

return Resource(XYZ)

 

I know there's an elegant way to do this without having to list all 10 possibilities every time for each of the 10 sections, but I'm not getting anything to work yet.

 

I'm also trying to point to graphic images saved on a Windows server, so I'm trying to reference graphic images at \\servername\filepath\folder\info\graphicfile.jpg which is compounding my problems by giving me errors related to the back slashes.

 

Hope that makes sense.

Thanks!

Kim

Edited by Kim
Link to comment
Share on other sites

Thanks, Dan.

I'm not sure what the replace is doing?

 

I maybe overthinking this.

I have 10 spaces where a user can insert 10 different logos. And 10 corresponding places under each logo to put formatted text resources. I'm not currently at my computer to check, but am wondering if the formatted text resource allows for the insertion of a graphic? Then I could marry the proper logo with its corresponding text from the start in one resource and just have 10 variable blocks of info instead of trying to create rules to put 2 pieces together?

Link to comment
Share on other sites

Thanks, Dan.

I'm not sure what the replace is doing?

It's removing the last period (dot), and everything after it, from the field value, effectively removing the extension, so that "ABC.jpg" becomes "ABC", etc.

I maybe overthinking this.

I have 10 spaces where a user can insert 10 different logos. And 10 corresponding places under each logo to put formatted text resources. I'm not currently at my computer to check, but am wondering if the formatted text resource allows for the insertion of a graphic?

Well, you can insert an inline graphic anywhere in text, but you have to write a rule to do it.

Then I could marry the proper logo with its corresponding text from the start in one resource and just have 10 variable blocks of info instead of trying to create rules to put 2 pieces together?

It sounds like what you want is a Repeatable Component, aka a Template page, where you can lay out both the text and graphic frame, then call out the Repeatable Component as needed in the main flow of the text.

 

Or maybe a table is a better approach. But at this point, I've reached the limit of my imagination of what your job looks like without seeing the files. Collecting up what you have so far and attaching it here might provide me with the insight needed to make more specific suggestions.

Link to comment
Share on other sites

Sorry for my slow response, Dan. I've been out of the office.

 

I realized I was overthinking things and that your initial answer is actually a good solution.

 

The last issue I'm having is that there are a couple of logos that do not have a corresponding formatted text resource. So I'm getting a placeholder {RUL-***} showing when there is an error of No Resource and I need it to just be blank.

 

How do I properly return NullResource when there isn't a formatted text resource?

 

I realize this doesn't work, but I figure I need something along the lines of:

 

if (Resource (Field("Logo1").replace(/\..+$/,'') == "None"))

return NullResource();

else

return Resource (Field("Logo1").replace(/\..+$/,''));

 

Thanks!

Kim

Link to comment
Share on other sites

Sorry for my slow response, Dan. I've been out of the office.

 

I realized I was overthinking things and that your initial answer is actually a good solution.

 

The last issue I'm having is that there are a couple of logos that do not have a corresponding formatted text resource. So I'm getting a placeholder {RUL-***} showing when there is an error of No Resource and I need it to just be blank.

 

How do I properly return NullResource when there isn't a formatted text resource?

 

I realize this doesn't work, but I figure I need something along the lines of:

 

if (Resource (Field("Logo1").replace(/\..+$/,'') == "None"))

return NullResource();

else

return Resource (Field("Logo1").replace(/\..+$/,''));

 

Thanks!

Kim

For a text rule, just return an empty string.

var resName = Field("Logo1").replace(/\..+$/,'');
if (!resName || resName == "None")
   return "";
//else
return Resource(resName);

Link to comment
Share on other sites

Thanks for the fast reply.

When I try that I get an error that there is no resource named ***

See attached.

Okay, so you don't have a resource named "ACC-AmericasMart". What is the data field value that the rule is using? Is it something like "ACC-AmericasMart.jpg"? What do you want to happen when the data has that value?

 

Again, I'm looking at your job through a keyhole, based on a very small bit of explanation. It's hard for me to guess at exactly what you're trying to do.

Link to comment
Share on other sites

Sorry, screen grabs do help don't they? Please see attached.

 

I've got a folder of logos and the user can choose 10 of them to insert on a page. Most of the logos (but not all) have a blurb of text (which I have as a separate formatted text resource) inserted under the logo. There are 3 you will notice in the screen grab which do not have a formatted text resource and are showing the placeholder {RUL}.

 

My rules are: (I've got 10 of each of these rules for Logos 1-10)

 

return CreateResource (Field("Logo1"));

 

and

 

var resName = Field("Logo1").replace(/\..+$/,'');

if (!resName || resName == "None")

return "";

//else

return Resource(resName);

 

Thanks again for your help.

Kim

LogoRuleExample.jpg.e2448e247abc381b348bfd23ce09930f.jpg

Link to comment
Share on other sites

Sorry, screen grabs do help don't they? Please see attached.

Well, normally, yes, a picture is worth a thousand words. Unless it's like the picture you posted previously, which is just a picture of a box of text, like an error message, in which case it's better to just hit Ctrl-C on the keyboard to copy the text of the message, and paste that here. Or unless it's a graphic like you just posted, which is so downsampled that I can't read the text on it.

 

Also, a picture of the output is fine, but what I really need to understand how you got to that output is the FusionPro template. Or at the very least, the actual output PDF would be better than a picture of the output, especially, if, again, the picture is so downsampled that it's impossible to read any text on it.

 

At any rate, it would be more helpful if you could answer the specific questions I asked:

What is the data field value that the rule is using? Is it something like "ACC-AmericasMart.jpg"? What do you want to happen when the data has that value?

Unfortunately, this doesn't really answer those questions:

I've got a folder of logos and the user can choose 10 of them to insert on a page. Most of the logos (but not all) have a blurb of text (which I have as a separate formatted text resource) inserted under the logo. There are 3 you will notice in the screen grab which do not have a formatted text resource and are showing the placeholder {RUL}.

Okay, so which of the rules you list below is called "RUL"? And what's the message in the composition log file that corresponds to that output? (You'll need to actually run a composition instead of just a Preview.)

 

My rules are: (I've got 10 of each of these rules for Logos 1-10)

 

return CreateResource (Field("Logo1"));

 

and

 

var resName = Field("Logo1").replace(/\..+$/,'');

if (!resName || resName == "None")

return "";

//else

return Resource(resName);

That information is fine, and I don't think there's necessarily anything wrong with those rules, but again, without the rest of the template, I don't know how those rules got you to the output you posted, which I can't really read anyway.

 

I am trying to help you, but I need a little more to go on.

Link to comment
Share on other sites

Yes, the value of the Logo1 field in the database is ACC-AmericasMart.jpg

 

When Logo1 has a value of ACC-AmericasMart.jpg, then the logo file with that name should show in the top box (which uses the first rule I posted).

The formatted text resource should show underneath the logo (those resources are defined as the filename without the .extension). In the case of this logo, there is not a resource named ACC-AmericasMart and the error occurs.

 

I was trying to give you a grab showing all 10 logo boxes with their 10 corresponding formatted text resource boxes. Due to size restrictions on the forum, I couldn't make too large of a grab. Besides, it's not important to be able to read the text under the logos. It's just the formatted text resource with info like a Contact Name, email address, URL, etc.

 

The second rule that you were trying to help me with is where there isn't a resource and it's displaying {RUL_LogoTxt_01} instead of being blank.

 

Here's the pertinent info from the log:

 

RUL_LogoTxt_01, line 5: Error: In Resource(), no resource named ACC-AmericasMart

Composing record #1, input record 1

Value for variable RUL_LogoTxt_01 not found in instance data

 

Hope that helps.

Kim

Link to comment
Share on other sites

Okay, so you still haven't told me which of the rules is the one named "RUL_LogoTxt_01". Is it this one?

var resName = Field("Logo1").replace(/\..+$/,'');
if (!resName || resName == "None")
return "";
//else
return Resource(resName);

And if the resource isn't found, you want to show nothing? Then I think this will work:

var resName = Field("Logo1").replace(/\..+$/,'');
if (!resName || resName == "None")
return "";
//else
try { return Resource(resName); }
catch (e) { return ""; }

Or actually, just this:

var resName = Field("Logo1").replace(/\..+$/,'');
try { return Resource(resName); }
catch (e) { return ""; }

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...