Jump to content

Repeatable Component Properties


step

Recommended Posts

Is there a way to access the properties of a Repeatable Component? Even if it's read only? Something like:

var template = new FPRepeatableComponent('myTemplateName');
return template.width;

 

I have a repeatable component that I'd like to repeat up to 3 times and center on a sheet that is 11 inches wide. In order to do this, (I assume) I'd have to build the repeatable component to the size of the component itself (11"/3 (potential components)). I can force the template to the center of a text frame by adjusting the text inset of the text frame based on how many repeatable components I have like so:

(OnRecordStart)

var template = new FPRepeatableComponent('myTemplateName');
var frame = FindTextFrame("My Text Frame");
var numberOfTemplates = 2;
var templateSize = (3.3*7200)* numberOfTemplates; // inches
var frameSize = frame.width;
var indentSize = (frameSize-(templateSize))/2;
frame.columns = numberOfTemplates;
frame.textInsetX = indentSize;
frame.content = template + template;

 

But I'd like this rule to be a little more scalable to use with other repeatable components that aren't 3.3". Ideally I'd be able to make the edits in red:

var template = new FPRepeatableComponent('myTemplateName');
var frame = FindTextFrame("My Text Frame");
var numberOfTemplates = 2;
[color="Red"]var templateSize = (template.width)* numberOfTemplates; // inches
[/color]var frameSize = frame.width;
var indentSize = (frameSize-(templateSize))/2;
frame.columns = numberOfTemplates;
frame.textInsetX = indentSize;
frame.content = template + template;

 

Is this possible? Is there another way to center a repeatable component within a larger text frame? Is this a feature that is available in a later version of FP than I am currently running (8.2.7)? Any tips would be greatly appreciated!

Link to comment
Share on other sites

As a side note, I should mention that the 'numberOfTemplates' variable is being determined dynamically based on a function that returns the 1,2, or 3 repeatable components based on whether fields "A", "B", and "C" have values:

var result = Rule("Headline");
var numberOfTemplates = (NormalizeEntities(result).match(/template/g).length)/2;
.
.
.
frame.content = result;

 

So even though I hardcoded the value in my above example, the OnRecordStart Callback is still capable of adjusting for single, double, or triple repeatable components.

Link to comment
Share on other sites

Is there a way to access the properties of a Repeatable Component? Even if it's read only? Something like:

var template = new FPRepeatableComponent('myTemplateName');
return template.width;

Unfortunately, no. The FPRepeatableComponent object doesn't really know anything about the Template page it's calling out. It just generates some tags that say, "Try to find a Template page with this name and use these variables with it." (Before the FPRepeatableComponent was added, you could still call out Templates with manual tagging.) The actual instantiation of the Template, merging in variables, setting the content into a text frame, and then actually typesetting the text, all happens long after the rules have been run and the FPRepeatableComponent object has generated its tags.

Is there another way to center a repeatable component within a larger text frame?

Not really. But there may be another way to accomplish whatever it is that you want to output. Maybe a table would be more appropriate as a generalized solution. It's hard to offer more specific suggestions without seeing more of the job.

Is this a feature that is available in a later version of FP than I am currently running (8.2.7)?

Not exactly. But, in FusionPro 9.0, the FindTextFrame and FindGraphicFrame functions were enhanced to allow access to frames on Overflow and Template pages, as well as with frames on Body pages. So, in FusionPro 9, just because you can't get information about the Template page itself, that doesn't mean you can't get information about frames on that Template page. Just give a frame on the page a unique name, and then you can use the FindTextFrame or FindGraphicFrame function to get an object with properties like width and height.

Link to comment
Share on other sites

Unfortunately, no. The FPRepeatableComponent object doesn't really know anything about the Template page it's calling out. It just generates some tags that say, "Try to find a Template page with this name and use these variables with it." (Before the FPRepeatableComponent was added, you could still call out Templates with manual tagging.) The actual instantiation of the Template, merging in variables, setting the content into a text frame, and then actually typesetting the text, all happens long after the rules have been run and the FPRepeatableComponent object has generated its tags.

 

Thanks, Dan. I was afraid that may have been the response but that does help explain why those properties aren't accessible.

 

Not really. But there may be another way to accomplish whatever it is that you want to output. Maybe a table would be more appropriate as a generalized solution.

 

Are repeatable components capable of being inserted into a table? I hadn't had much success with that and wasn't able to find much insight regarding it on the forums.

 

Unfortunately, due to company policy, I am unable to upload my template to the forum. My repeatable component is essentially variable text placed on top of a variable graphic. I tried some trickery with adjusting superscript offset to force the text onto the graphic but I choose the repeatable component route because of the added CopyFit functionality for the variable text in each instance of the component. Using a table versus adding columns to a text frame would be nice, though.

Link to comment
Share on other sites

Are repeatable components capable of being inserted into a table? I hadn't had much success with that and wasn't able to find much insight regarding it on the forums.

I didn't mean that you should try to put a repeatable component inside of a table (that doesn't really work). I meant that you might be able to use a table in place of the repeatable components. I don't really know for sure whether that would work in your case without seeing more of the job, though.

Unfortunately, due to company policy, I am unable to upload my template to the forum.

I don't necessarily need to see the entire job in order to make more specific suggestions. But I need a little more than just the rule to go on. Can you dummy out the data? Or can you at least mock up what you want the output to look like?

 

You could always inquire about paid consulting work if you don't want to share the job here. (Sometimes free advice is worth what you pay for it anyway.)

My repeatable component is essentially variable text placed on top of a variable graphic. I tried some trickery with adjusting superscript offset to force the text onto the graphic but I choose the repeatable component route because of the added CopyFit functionality for the variable text in each instance of the component.

Yes, that would be hard to duplicate in a table.

Using a table versus adding columns to a text frame would be nice, though.

I'm not sure what you mean here. Where are you using columns? Again, it's hard to follow what you're saying without even a peek at the job.

 

At any rate, without knowing more about the job, I think your best bet here is to upgrade to FusionPro 9, name a frame on your Template page, and use the FindTextFrame function to query its size.

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