Go Back   MarcomCentral (PTI) and FusionPro User Communities > Software-Related Talk > The JavaScript Library

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old October 23rd, 2012, 10:04 AM
juliazo juliazo is offline
Junior Community Member
 
Join Date: Jun 2012
Posts: 22
Question How do I get the name of the current frame?

Hi all,

I'm trying to find out if it's possible to get the name of the current text frame (for example "01") so I can then use it in the rule.

In other words, it'd be great if the FindTextFrame() function could be used to find the name of the current text frame, as opposed to the name of the specific text frame that one passes in the function.

Here's the scenario:

I have 18 pages with 8 text frames on each, and I'd like to be able to use only one rule that uses the frame names as variables to modify the specifics of the rule, as opposed to having to write one distinct rule for each of the 144 text frames.

Hope this is clear, let me know if not and I can provide more info.

Thanks!

Julian
Reply With Quote
  #2  
Old October 23rd, 2012, 10:39 AM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,327
Default Re: How do I get the name of the current frame?

In FusionPro 8, you can check the "Re-evaluate this rule for every text flow" box on the Rule Editor dialog, and then you can use the FusionPro.Composition.CurrentFlow.name property, like so:
Code:
var currentFrame = FindTextFrame(FusionPro.Composition.CurrentFlow.name);
Or, in your case, you probably want to do something like this:
Code:
switch (FusionPro.Composition.CurrentFlow.name)
{
    case "A":
        // something specific to frame "A"
        break;
    case "B":
        // something specific to frame "B"
        break;
    // etc. ...
}
If you're in an earlier version of FusionPro (6 or 7), then you can't have a standard rule work differently for different frames, so the above won't work. However, you can still use the FindTextFrame function in a loop in the OnRecordStart callback rule to "inject" different contents into each frame. The OnRecordStart logic might look something like this (depending on your frame naming convention):
Code:
for (var page = 1; page <= 18; page++)
{
    for (var frameNum = 1; frameNum <= 8; frameNum++)
    {
        var curFrameName = "P" + page + "-" + frameNum;
        var currentFrame = FindTextFrame(curFrameName);
        currentFrame.content = "The content for frame " + curFrameName;
    }
}
Actually, you might find that last strategy works best for you, even in FusionPro 8.
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral
LinkedIn

I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@marcom.com.

Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@marcom.com. Paid consulting work may be required to fulfill your template-building needs.

This is a publicly viewable forum. Please DO NOT post fonts, or other proprietary content, to this forum. Also, please DO NOT post any "live" data with real names, addresses, or any other personal, private, or confidential data.

Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages.

Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance.

Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support.

How To Ask Questions The Smart Way

The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript.

Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5.

return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)});
Reply With Quote
  #3  
Old October 23rd, 2012, 11:10 AM
juliazo juliazo is offline
Junior Community Member
 
Join Date: Jun 2012
Posts: 22
Default Re: How do I get the name of the current frame?

Thank you, Dan!!

You absolutely nailed it, the FusionPro.Composition.CurrentFlow.name is what I was looking for. Thanks again!
Reply With Quote
  #4  
Old October 31st, 2012, 04:04 PM
juliazo juliazo is offline
Junior Community Member
 
Join Date: Jun 2012
Posts: 22
Default Re: How do I get the name of the current frame?

Quote:
Originally Posted by Dan Korn View Post
In FusionPro 8, you can check the "Re-evaluate this rule for every text flow" box on the Rule Editor dialog, and then you can use the FusionPro.Composition.CurrentFlow.name property, like so:
Code:
var currentFrame = FindTextFrame(FusionPro.Composition.CurrentFlow.name);
Or, in your case, you probably want to do something like this:
Code:
switch (FusionPro.Composition.CurrentFlow.name)
{
    case "A":
        // something specific to frame "A"
        break;
    case "B":
        // something specific to frame "B"
        break;
    // etc. ...
}
If you're in an earlier version of FusionPro (6 or 7), then you can't have a standard rule work differently for different frames, so the above won't work. However, you can still use the FindTextFrame function in a loop in the OnRecordStart callback rule to "inject" different contents into each frame. The OnRecordStart logic might look something like this (depending on your frame naming convention):
Code:
for (var page = 1; page <= 18; page++)
{
    for (var frameNum = 1; frameNum <= 8; frameNum++)
    {
        var curFrameName = "P" + page + "-" + frameNum;
        var currentFrame = FindTextFrame(curFrameName);
        currentFrame.content = "The content for frame " + curFrameName;
    }
}
Actually, you might find that last strategy works best for you, even in FusionPro 8.
Hello,

Dan, thanks again for your help. Since FusionPro.Composition.CurrentFlow.name only works during composition, and I'd like to be able to test for my rules when building the template, I decided to give it a try with the OnRecordStart rule that you suggested, and it worked great to push the content as I needed!

However, I'm running into a small issue with text formatting (not sure if this is the right forum/thread to be asking this, so please let me know if that's the case):

When pushing content to the frame, I'm appending tags also to format the text (which I get by creating a Formatted Text resource, formatting text the way I need it, then viewing its source). The tags are able to specify a font and a color and a size for the text without issues, but my text shows up in the "left" quadrant, even when the tags specify "center" (the tag is quad="C").

Do you know if this is expected behavior when pushing content to a text frame, or if I should submit a support ticket?

Thanks!

Julian

Adobe Acrobat Pro v9.5.2
FusionPro VDP Creator 8.2.5
Mac OS X 10.8.2
Reply With Quote
  #5  
Old November 1st, 2012, 11:09 AM
esmith's Avatar
esmith esmith is offline
Senior Contributor
 
Join Date: Oct 2008
Location: Charlotte, NC
Posts: 870
Default Re: How do I get the name of the current frame?

quad="c" is a property of the <p> tag rather than a standalone tag. Can't tell from your post is that is how you are using it?
Code:
<p quad="c">
__________________
Eric Smith
Content Developer
Classic
FP 9.3.6, MAC OSX 10.9.4, Acrobat 11.0.09
Reply With Quote
  #6  
Old November 1st, 2012, 11:30 AM
juliazo juliazo is offline
Junior Community Member
 
Join Date: Jun 2012
Posts: 22
Talking Re: How do I get the name of the current frame?

Thanks for the reply, Eric!

I was in the process of looking up the contents of the variable I'm using to add the formatting tags so that I could post them on the thread...and it was then that I realized that I had a typo in the variable name. I feel kinda dumb now, but at least the problem is no more, so thank you for helping me discover it!

Julian
Reply With Quote
  #7  
Old November 1st, 2012, 11:56 AM
juliazo juliazo is offline
Junior Community Member
 
Join Date: Jun 2012
Posts: 22
Default Re: How do I get the name of the current frame?

Just for kicks, here's the logic I'm using (hopefully this can help someone down the line)

Rule added to OnRecordStart:

Code:
 for (var frameNum = 1; frameNum <= Field("TagCount"); frameNum++)
        {
            var curFrameName = "N_" + frameNum;
            var currentFrame = FindTextFrame(curFrameName);
            currentFrame.content = foodName2 + softReturn(Field("FoodName_" + frameNum));
        }
"TagCount" and "FoodName_##" are user-driven variables.

"foodName2" is a JavaScript Global variable containing the formatting tags:

Code:
var foodName2 = '<p style="(no style)" br="false" override="true" quad="C" leading="260" findent="0" lindent="0" rindent="0" leadbefore="0" leadafter="0" widows="1" kerning="true" hyphenate="false" skipifempty="true" skipifemptyvar="false" noparabreakoncopyfit="false"><tracking newsize="0"><f name="Helvetica Neue Light"><z newsize="22.0"><color name="202-15/100/70/25">'

This rule effectively pushes the content to the text frames, which are named "N_1" through "N_48".
Reply With Quote
Reply

Tags
frame, object, text frame, variables

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 06:55 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) 2011, PTI Marketing Technologies™, Inc.