Jump to content

Best way to configure text


bkurzbuch

Recommended Posts

Still fairly new to javascript and have been working on the attached screen shot to no avail. There are 2 pricing options on my flyer (Ultimate Advisor Plus & Ultimate Advisor). If there is just 1 plan selected then Ultimate Advisor Plus does not appear and Ultimate Advisor mover to the left in its position. I have that working. My problem is that not all three pricing options are used at a time(i.e. Individual, Two-Party and Family and in addition to that, the end text "month". is a variable also and will never be empty. I created a switch rule with 2 text resources, but am sure this was the wrong way to go.Code below. Any advise or help on how to format this would be greatly appreciatied. I have 7 variable fields for this block of text. One for each price and a additional one for the payment option which will be the same for all price records once selected. Thanks for the help.

 

 

switch (Field("Number of Plans").toLowerCase())

{

case "1".toLowerCase():

return Resource("Individual Pricing");

case "2".toLowerCase():

return Resource("Individual Pricing plus");

default:

return "";

}

Pricing_Variable.jpg.a3b3af77046c77d20d9f4aa69449ee32.jpg

Link to comment
Share on other sites

How do you determine if a pricing option should show up? Is it based on whether or not the field contains numbers? If so, you could test to see if the field contains anything after you remove everything that isn't numbers, if it does return the field, if it doesn't, you'll know it was empty:

var field = "$70.00 per month"; // Your field name here
return (field.replace(/[^\d]/g,'')) ? field : '';

 

If you post your collected template and a sample of your data, someone might be able to give a more specific answer.

Link to comment
Share on other sites

It could just be something fishy going on with my computer but I still wasn't able to get a whole lot out of that attachment since I don't have your fonts and for some reason all of the rules you had applied to the text frames did not come over for me. You must be running a different version of FP than I am.

 

Anyway, the way I would do this is to have one rule that returns your plans to your text box. And then I'd set the text box (or a text box that I assumed was supposed to have your plans in it) to be two columns. That way you can force the first plan to return in the first column and the second plan in the second column and if there's only one, it adjusts. You could do the same thing with a table if you wanted but that seems a little overkill for a textbox that is only displaying the plans. Here's the code I came up with:

function Plan(title, individual, twoParty, family, unit){
   var fonts = { planTitle: '<span font="TisaOT" pointsize="10.0">',
                 optionTitle: '<span font="TisaSansOT-Medium">',
                 option: '<span font="TisaSansOT-Light">'};

   title = fonts.planTitle + title + '</span>';
   var options = [["Individual: ", individual],
                 ["Two-Party: ", twoParty],
                 ["Family: ", family]];

   options = options.filter(function(s){return s[1];});

   if (!options.length){
       return '';
   }

   options = options.map(function(s){return fonts.optionTitle + s[0] + '</span>' + fonts.option + '$' + FormatNumber("###.00", s[1]) + ' ' + unit + '</span>';});
   options.unshift(title);
   return options.join("<br>");
}

var uaPlus = Plan("UltimateAdvisor® Plus", Field("UA Plus Individual"), Field("UA Plus Two-Party"), Field("UA Plus Family"), Field("Pay Period"));
var ua = Plan("UltimateAdvisor®", Field("UA Individual"), Field("UATwo-Party"), Field("UA Family"), Field("Pay Period"));
return [uaPlus,ua].filter(String).join('<p verticalstart="topofcolumn">');

 

I've attached a screenshot. You'll notice that the text frame editor has that text frame's columns set to "2" (highlighted in green).

screenshot.pdf

Link to comment
Share on other sites

Hi Ste Pennell

Gave that a shoot and I get just the rule showing in the box. i believe its because the whole thing driving this is field "Number of Plans" when the number is 1 it is just Ultimate advisor and 2 is Ultimate advisor Plus, but where i can motive your code is above me. If you could point me in the right direction I think i can get it from there. Also i need to motive it to return the ® as a superscript. Thanks for the help

Link to comment
Share on other sites

Make sure you have "Treat return strings as tagged text" checked in the rule editor.

 

You can superscript the registration mark like this:

function Plan(title, individual, twoParty, family, unit){
   var fonts = { planTitle: '<span font="TisaOT" pointsize="10.0">',
                 optionTitle: '<span font="TisaSansOT-Medium">',
                 option: '<span font="TisaSansOT-Light">'};

   title = fonts.planTitle + title + '</span>';
   var options = [["Individual: ", individual],
                 ["Two-Party: ", twoParty],
                 ["Family: ", family]];

   options = options.filter(function(s){return s[1];});

   if (!options.length){
       return '';
   }

   options = options.map(function(s){return fonts.optionTitle + s[0] + '</span>' + fonts.option + '$' + FormatNumber("###.00", s[1]) + ' ' + unit + '</span>';});
   options.unshift(title);
   return options.join("<br>");
}

var uaPlus = Plan("UltimateAdvisor[color="Red"]<superscript>®</superscript>[/color] Plus", Field("UA Plus Individual"), Field("UA Plus Two-Party"), Field("UA Plus Family"), Field("Pay Period"));
var ua = Plan("UltimateAdvisor[color="Red"]<superscript>®</superscript>[/color]", Field("UA Individual"), Field("UATwo-Party"), Field("UA Family"), Field("Pay Period"));
return [ua,uaPlus].filter(String).join('<p verticalstart="topofcolumn">');

Link to comment
Share on other sites

It could just be something fishy going on with my computer but I still wasn't able to get a whole lot out of that attachment since I don't have your fonts and for some reason all of the rules you had applied to the text frames did not come over for me. You must be running a different version of FP than I am.

The job was created in FusionPro 9.3. Templates built in 9.2 and 9.3 are all 16-bit Unicode, and can't be opened in earlier versions of FusionPro, unless the "Preserve 9.1 Collect Format" box was checked in the Collect dialog.

 

In general, though, it's not a good idea to open up a job in an older version of FusionPro than the one in which it was created, as it could be using any number of features which are present in the newer version but not in the older one. (Fortunately for me, I always have the latest version, and often a version that hasn't yet been released. So I can look at pretty much any job.)

 

Of course, it would be easier to know whether the job was created in a newer version if bkurzbuch would do what Step is already doing, and specify the version he's using in his signature.

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