Jump to content

Sending parameters to Templates


DSweet

Recommended Posts

When I program a FPRepeatableComponent (what used to be called a "Temple I mean Template" in older versions) and I hit validate in the rules editor, I get a results pop-up listing the template-page that was called plus a heading of "Template variables:". How am I able to code and pass these template variables?

 

I haven't found much in the manual about this. It's mostly just repeats from the ancient DataLogics manual. I want to pass specific text and graphic variables for each FPRepeatableComponent that I program. Can I tie these in with specific rules or actually pass a rule name as a variable?

 

For instance say that when I call a template for the first time I want to pass the results of a graphic rule based on Field("BK1"), but the second or third time that I call it for the same record I want to use the same template page but base the rule on a value in Field("BK2"), or Field("BK3"). How do I pass the field to the same rule and how is the rule then coded to accept a variety of parameters? Is the rule then just a function?

 

I would like to see a more expanded upon manual section for the FPRepeatableComponent. Or maybe even a video tutorial would explain it better since we could be shown exactly how the programming flows from one to another and see an example of how it is coded.

 

Expanding the program and allowing it to grow to meet the needs of us programmers is great, but not if the changes aren't fully explained; or worse if the new features are just mentioned but not even talked about at all.

 

Thanks.

.

Link to comment
Share on other sites

O.K. I was finally able to find the small section that describes how you add a graphic to the call for the template page. However there is no explaination as to how the graphic box is defined - with or without a rule, with or without a name, NOTHIN'. Page 133 simply state "C - The variable graphic frame HAS <<Customer Picture>>". Is "Customer Picture" the name of a variable, of a rule, or of the Graphic Box itself? If it's the name of a variable then how do I pass it if it's not in the datafile?

 

I am able to create the template page calling rule and pass the variable for the card background in the template by using...

 

var cardBotMid = new FPRepeatableComponent("OP_Back");

cardBotMid.AddGraphic("Shell_OP", Resource("OP_BackShell.pdf"))

return cardBotMid

 

"OP_Back" is the name of the Template Page

"Shell_OP" is the name given to the Graphic Box on the page

 

When I hit validate in the rules editor it returns that I'm calling the template page "OP_Back" and that I want to pass the graphic variable "OP_BackShell.pdf" inside the frame Shell_OP.

 

When I compose the document the text variables that are already placed directly on the template page OP_Back come out correctly so it's calling the correct template page, but the graphic is blank. I've tried changing the AddGraphic statement to reflect the RULE NAME that places the graphic inside the box on that template page, but it is still blank.

 

I guess I just need a bit of clarification. HELP!

.

Link to comment
Share on other sites

Does anyone have an idea on how to do this? The project that I'm working on is supposed to go live by the end of the month.

 

All I need to know is how to pass a variable graphic name in the cardBotMid.AddGraphic() command. Any way that I've tried (via rule, via graphic hole, via template) all come up blank.

.

Link to comment
Share on other sites

I tried to use template pages a month ago and had no luck either. In fact, reading over this thread, it sounds like you are much farther along then I ever got before giving up. However, for your sake, I read through the UserGuide again and have a suggestion:

 

On page 124, it states that you should manually type in the name of the variable in the Field/Rule combo box for graphics or the variable drop down in the text editor for text (and then insert that "virtual" variable into the editor).

 

The reference needs to be in a tagged file, so assuming your data is in the standard CSV-style format (field names in row one and each record's data on a single row) as opposed to an XML-like file, you would need to add a separate resource file with the names of your text/graphics using the XML tag format (see pg 121 for example which is explained on pg 124) :

<story copyhole="Shell_OP">
  <template name="OP_Back">
     <story copyhole=("virtual" variable name added manually to text frame in template)>data</story>
     <graphic copyhole=("virtual" variable name added manually to frame in template) file=(file name)>
  </template>

  -- use as many template tags as necessary for your data --
  <template name="OP_Back">
  </template>
</story>

In this scenario, you would then have a text frame on your base page with a manually inserted variable named "Shell_OP". On the template page (named "OP_Back" in the "Page Usage..." dialog), you'd have your text/graphic frames with manually added variable names that match the names of your story/graphic tags in your resource file.

 

SIDE NOTE: Page 121 of the UserGuide mentions using a text frame on the base PDF. Your 2nd post makes it sound like you currently have a graphic frame on your base page.

 

In theory, when composing a record, the manually added variable "Shell_OP" would 'link' to the tagged resource of the same name, pull in an instance of the template per the <template> tag, and populate the template frames with the data contained in the sub-tags whose names match the variables added manually to the template's frames.

 

I am assuming it should be possible to build the tagged resource for each record from the input data, perhaps in an onRecordStart callback rule, create a resource from the result, and then populate the template with that information.

 

Of course, I haven't tried any of this myself. I am counting on you to be the guinea pig, and report back with your results! (Is your head spinning? I know mine is.)

Link to comment
Share on other sites

I was going to ask where you came up with the AddGraphic property, but I just found the UserGuide "addendum" for FP 6.x.

 

Given this new plethora of knowledge, it appears that you can now skip the XML-tagged resource stuff and just create a JS rule to generate the necessary information. What stays the same (I think) is that the names of the copyholes (bolded in the example below taken from addendum):

var catalogItem = new FPRepeatableComponent([b]“ItemTable”[/b]);
catalogItem.AddGraphic([b]“Picture”[/b], “Pens.tif”);
catalogItem.AddTextVar([b]“Item”[/b], “Pens”);
catalogItem.AddTextVar([b]“Description”[/b], “Our pens...your logo.”);
return catalogItem;

would be added as manual variables to the respective frames in your template as well as the text frame on your base page that calls for the template.

 

Quite easier with the new FPRepeatableComponent object, but still looking forward to you posting your results. :cool:

Link to comment
Share on other sites

Hi David,

 

I apologize for the documentation issues. I think I can clarify this for you.

O.K. I was finally able to find the small section that describes how you add a graphic to the call for the template page. However there is no explaination as to how the graphic box is defined - with or without a rule, with or without a name, NOTHIN'. Page 133 simply state "C - The variable graphic frame HAS <<Customer Picture>>". Is "Customer Picture" the name of a variable, of a rule, or of the Graphic Box itself? If it's the name of a variable then how do I pass it if it's not in the datafile?

It's the name of a graphic variable, which you can simply type into the drop-down combo box on the Graphic Frame Properties palette for a graphic frame on the Template page. The variable won't be listed in the drop-down options since it's not coming directly from a Graphic rule or field, but you can still type in whatever variable name you want. Likewise, you can enter any text variable in the Variable Text Editor by typing the name into the drop-down combo there and clicking Insert.

 

In addition to applying Template Page-specific variables, you can also use this "type in the variable name" method for variables added in code with the FusionPro.Composition.AddVariable and FusionPro.Composition.AddGraphicVariable functions.

I am able to create the template page calling rule and pass the variable for the card background in the template by using...

 

var cardBotMid = new FPRepeatableComponent("OP_Back");

cardBotMid.AddGraphic("Shell_OP", Resource("OP_BackShell.pdf"))

return cardBotMid

 

"OP_Back" is the name of the Template Page

"Shell_OP" is the name given to the Graphic Box on the page

Again, for both text and graphic frames, it's the variables that matter here, not the frame names. So, "Shell_OP" should be the variable applied to the Graphic frame on the Template page, as opposed to the name of the frame. In other words, you type it into the second box on the Graphic Frame Properties palette, not the first. The name of a Template Page frame doesn't really have any relevance in a FusionPro Desktop composition (although you could use the name to access the frame with the DIF Control API for an FP Server job.)

 

Hopefully this helps. I think it's just a minor thing you need to do to apply the variable name instead of the frame name. I can post an example if you like as well.

Link to comment
Share on other sites

  • 1 month later...

O.K., I've got my template working the way I would like it to work, even with the repeatable items templates...sort of. I know that there may be a more efficient way of doing it but for now it works and I'll try to tweak it to get it sleeker and more compact. However, up to now I've only been composing the output to be 1-up single pages in a single large pdf file.

 

I just now assigned an imposition to it and it blew up in my face - or more accurately disappeared before my eyes. Some (not all just some) of the repeatable graphic components do not appear when the imposition is applied and I get a warning/error prompt for every data record in the composition log file that the repeatable item rule I created has "No value associated to graphic copyhole". These same graphics do however show up in the on screen preview and when the same template and data file are used in a non-imposed composition without errors of any kind. At first I thought that this might just be something with FP Server as in the past it has worked a little different than desktop - but I received the same results with desktop as well.

 

Is this a known bug?! Should I be putting this is the reported bug section of this forum? I can't really upload a zip file here with all the resources for it is nearly 14MB.

 

Which one of you lucky "Printables" wants to take a whack at it? :D

.

Link to comment
Share on other sites

Is this a known bug?! Should I be putting this is the reported bug section of this forum? I can't really upload a zip file here with all the resources for it is nearly 14MB.

 

Which one of you lucky "Printables" wants to take a whack at it? :D

.

Since the issue seems like it's extremely specific to your job, I suggest contacting Support.

Link to comment
Share on other sites

Seriously.. when is the NEW documentation comming out

I'm going to have to second that request, especially with the repeatable component issue in this thread. I have a new project which I *think* may be a good candidate for repeatable components, but since I'm not fully grasping the functionality via this thread (or via current documentation), I'm not able to determine if this is the way I should go.

Link to comment
Share on other sites

Eric,

 

Once you get the hang of it the ability to use the RepeatableComponents is actually rather simple (like most things - once you get the hang of it). ;)

 

You are sort of creating a temporary "OBJECT" element with properties that are text and/or graphic in nature. You are not defining a rule as in the rule editor, it's more like you are defining empty place holders or pseudo-functions that you can use in different places at different times but it doesn't have a set definition or variable set to it.

 

In the manuals example (pg 129 for version 6.1P1e) you will see that a text rule called "Catalogue" is first created and the script inside it defines the OBJECT "catalogItem" as a new FPRepeatableComponent as further defined by the template page previously created called "ItemTable". Catalogue is the actual text rule that you place within the FP Template wherever you want this Object to be placed.

 

Within catalogItem you are defining its properties which are made up of text and graphic items. These properties are like temporary functions which you can name and define as you go. Also, just like a function, depending on what parameter is passed to it for different calls, that function can have different output even when used simultaneously on the same page and within the same data record.

 

The commands catalogItem.AddGraphic("Picture", #####) defines one graphic property of catalogItem which you have named as "Picture" to be either a static graphic - as in the manual sample "Pens.tif" - or a field value in the data file or a variable graphic based on another rule. Whatever you pass to it during that specific call the graphic placeholder "Picture" will have that specific value.

 

The same concept goes for the text property items within the OBJECT catalogItem. The command catalog.AddTextVar("Item", #####) states that the text property you just defined as "Item" is to be filled with a text item that you now specify via a field or rule like the graphic example or as in the manual a set code of "Pens".

 

Now then...how to use this OBJECT and its set of properties. On the template page named "ItemTable" you will see a graphic and a 2 text boxes set up. When you click on the graphic box you would normally use the pull down menu in the pallette and select the defined rule that you created in the rules editor. However when you do this you will notice that there are no graphic rules defined! So then how do you enter in the graphic property for this. You simply put the cursor inside the space where the rule name goes and MANUALLY type in the name of the PROPERTY yourself. You would type in the name Picture and hit return. You then define the rest of the box features as you normally would in regards to alignment and proportional settings.

 

When you click into the text box that you want the property "Item" to go you will also notice that there are no text rules defined as "Item" in the pull down menu. The only one there is named Catalogue. Once again, you need place the cursor where you want this item to be positioned in the text box, then place the cursor within the pull down box and manually type in the name Item and click insert. A rule definition pops into place with the proper name <<Item>> in the text editor page.

 

Now how do you call this OBJECT on your main template page. This is where you need to use the only truly defined rule that was created - Catalogue. On your main page you create a TEXT box. This is a text rule even though it does contain graphic items. Think of it like an in-line graphic item that you created in a text rule. You place the rule Catalogue inside a text box that is large enough to hold the entire template page opening. If the box is not large enough you will get the infamous red bar along the bottom and unfortunately you cannot use the copyfit function on this.

 

This is the basics of the RepeatableComponent items that I have discovered and tested. You can code multiple graphic and text items within the script. You can use the same definition of the same RepeatableComponent in more than one rule, but each will use the same template page "ItemTable" as the layout for that OBJECT.

 

I know this is rather long and possibly more confusing than helpful. And there still seems to be a bug with using it. When I composed the template without any imposition is was just fine. When I used an imposition scheme (even just a 1-up scheme), the repeatable items did not show up. The programming engineers at Printable are hard at work looking into this now and I'll upate as I receive information on it.

 

Eric, you said that you were thinking about using something like this for an upcoming project of yours. I hope I haven't discouraged you from at least trying.

 

Good Luck,

:cool:

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...