Jump to content

Suppressing Mutiple Text Frames


Recommended Posts

Hi,

 

I need help with a js rule to suppress multiple text frames, based on 14 different logos. The text frames change position depending on which logo is used. Is there a way to combine these logos into groups? (See below)

 

9 logos = text frame A

4 logos = text frame B

1 logo = text frame C

 

Any suggestions? Please let me know if you need any other info.

 

Thanks,

J.Preve

Link to comment
Share on other sites

Are the logos also named A, B, C, etc.? If so, I would name each set of frames with a pattern, such as "Logo A 1", "Logo A 2", "Logo A 3", etc., then "Logo B 1", "Logo B 2", and so on. Then you can write the OnRecordStart code like so:

var LogoToUse = Field("Logo"); // expects "A", "B", "C", etc.
for (var c = Asc('A'); ; c++)
{
   var logo = Chr(c);
   if (logo == LogoToUse)
       continue;

   var frameName = "Logo " + logo + " 1";
   try { FindTextFrame(frameName); } catch (e) { break; }

   for (var i = 1; ; i++)
   {
       frameName = "Logo " + logo + " " + i;
       var frame;
       try { frame = FindTextFrame(frameName); } catch (e) { break; }
       frame.suppress = true;
   }
}

If the logos have arbitrary names (such as "cat", "dog", "fish"), then you need to name the frames accordingly ("Logo cat 1", "Logo dog 1", etc.), and use code like this:

var LogoToUse = Field("Logo");
var logos = ["cat", "dog", "fish"];
for (var l in logos)
{
   var logo = logos[l];
   if (logo == LogoToUse)
       continue;

   for (var i = 1; ; i++)
   {
       var frameName = "Logo " + logo + " " + i;
       var frame;
       try { frame = FindTextFrame(frameName); } catch (e) { break; }
       frame.suppress = true;
   }
}

Although, there are other ways to set up this kind of template. You could make three different Unused Body Pages, one for each logo, and activate the appropriate one in OnRecordStart with this single line of code:

FusionPro.Composition.SetBodyPageUsage(Field("Logo"), true);

You could also make a set of Repeatable Component pages with the different text frame configurations, and call out the appropriate one into a text frame on the Body page, in a text rule like so:

return new FPRepeatableComponent(Field("Logo"));

Link to comment
Share on other sites

HI Dan, Thanks for the quick response!

I'm not sure I understand this rule. Here is more information on the job. This will be a variable business card on the Digital Storefront. The customer will have 14 background logos to choose from a drop-down. The problem is, the text frames have various positions based on the background logo. All logos will use a specific text frame; "A", "B", or "C". I'm having a hard time writing a rule to suppress the other text frames and linking the logo graphics to the correct text frame. I apologize if I made this more confusing. :) Example Below:

Logo Graphic Names

sports medicine.pdf

neurosurgery.pdf

pain management.pdf

primary care.pdf

All of these logos will use text frame "B"

how do I suppress text frame "A" and "C"?

Thanks for your help!!!

Link to comment
Share on other sites

I think you want to do something like this:

var logoField = Field("logo"); // Your logo field
var logos = {
 A:[ // Logos that use frame "A"
   ],
 B:[ // Logos that use frame "B"
     "sports medicine.pdf",
     "neurosurgery.pdf",
     "pain management.pdf",
     "primary care.pdf"
   ],
 C:[ // Logos that use frame "C"
   ]
};

for (var frame in logos)
 FindTextFrame(frame).suppress = logos[frame].indexOf(logoField) === -1;

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