Jump to content

Need Help with inline graphic


Recommended Posts

You don't actually need a rule at all. You can simply select all of those lines in the Text Editor, click Paragraph, check the "Suppress if" box, and select "Containing Empty Variables."

 

That said, if you really want to write a rule, then instead of looking at this in a substractive way, i.e. trying to remove things when other things are not there, I would look at it in an additive way, and only actually output something when appropriate. Something like this:

var graphic = '<graphic file="yourFile.jpg" height=1000>';

var result = "";
for (var i = 1; i <= 3; i++)
{
   var fieldValue = Field("Product " + i);
   if (fieldValue)
       result += graphic + "<t>" + fieldValue + "<p>\n";
}
return result;

or:

var graphic = '<graphic file="yourFile.jpg" height=1000>';

var result = [];
for (var i = 1; i <= 3; i++)
{
   var fieldValue = Field("Product " + i);
   if (fieldValue)
       result.push(graphic + "<t>" + fieldValue);
}
return result.join("<p>\n");

Or, if you want to be a bit more JavaScript-y:

var graphic = '<graphic file="yourFile.jpg" height=1000>';

var result = [];
for (var i = 1; i <= 3; i++)
   result.push(Field("Product " + i));

return result.filter(String).map(function(e){return graphic + "<t>" + e;}).join("<p>\n");

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...