Jump to content

Table markup in a rule.


BAndreas

Recommended Posts

Hello all,

 

The business card I'm working with has a rule line to the left of the contact numbers (Direct:, Tel:, Fax: and Mobile. Can anyone shed some light on how I can adjust the length of that rule line depending on the amount of fields being used?

 

I have set up rules to return empty variables in the event that one of the four lines are not used. During a previous post, it was recommended (Dan Korn) that I set up a table with the rule line assigned to the left rows.

 

I've also created the tagged markup but need help generating a rule from this. Dan Korn: "Or, you could generate all the table markup in a rule and call the Field function as needed."

 

Can anyone provide a sample of what this might look like?

 

Very much appreciated,

 

Bill

Link to comment
Share on other sites

A very minimal example would be:

var myTable = '<table columns=1><column width=10000>';
myTable += '<row><cell>' + NormalizeEntities(Field("Name"));
myTable += '</table>';
return myTable;

Please refer to the FusionPro User Guide and the FusionPro Tags Reference Guide for detailed information about creating tables from tagged markup.

Link to comment
Share on other sites

Ok, as a beginner I can tell that this is going to be a painful process. It may be simpler to have three variable backgrounds with different rule lengths to correspond to the amount of contact numbers involved. Eventually I'll come to a point where I need to hide a row (for the sake of hiding the rule line.)

 

Maybe I should be applying the rule line to the left column with the expectation of the table adjusting itself accordingly based on a return ""; rule?

 

The user guide provides information about tags and tag markup, but nothing involving actually implementing them in a rule and applying it to the design. I'm sure having an understanding for this simple concept will make life easier moving forward.

 

Again, Thank you for the information.

Link to comment
Share on other sites

It may be simpler to have three variable backgrounds with different rule lengths to correspond to the amount of contact numbers involved. Eventually I'll come to a point where I need to hide a row (for the sake of hiding the rule line.)

I'm not sure that would be much simpler to implement, but there's often more than one way to skin a cat, as they say. There are even simpler ways to do what you're trying to accomplish. For instance, you could simply put a pipe | character (hit shift and the key above Enter on your keyboard) at the beginning of each line in the Variable Text Editor and turn on "Suppress if Containing Empty Variables" in the Paragraph Formatting dialog. You could increase the pointsize of the pipe character and set absolute leading to make the pipes appear as a solid vertical line. If you did this, you wouldn't need any JavaScript or tagged markup at all, similar to my suggestion in the previous thread.

Maybe I should be applying the rule line to the left column with the expectation of the table adjusting itself accordingly based on a return ""; rule?

That's kind of what I was alluding to above with the pipe character. But you don't need a return ""; rule because the "Suppress if Containing Empty Variables" should take care of that for you.

The user guide provides information about tags and tag markup, but nothing involving actually implementing them in a rule and applying it to the design. I'm sure having an understanding for this simple concept will make life easier moving forward.

"Applying" tags to the design is simply a matter of making a rule that returns the appropriate tagged markup to the composition. Here's a more fleshed-out example that I think is more specific to what you're trying to do:

function AddRow(FieldName, Label)
{
 try
 {
   if (Field(FieldName))
     return "\n  <row><cell><cell>" + (Label || FieldName + ":") + " " + Field(FieldName);
 }
 catch (e) {}
 return "";
}

var myTable = '<table columns=2 boxrules="left:Thin,Black" margins="top:10;bottom:10">'
myTable += '\n<column width=200><column width=100000>'

myTable += AddRow("Direct");
myTable += AddRow("Tel");
myTable += AddRow("Fax");
myTable += AddRow("Mobile");

myTable += '\n</table>';
return myTable;

You'll have to modify some of the numbers for column widths, margins, and such for your specific job. Again, though, you can probably accomplish this without a table too.

Link to comment
Share on other sites

ok, I'm very close to what I'm looking for. I used the code above to come up with a two column table which allowed the contents of each cell to be in alignment however, the cells are spaced too far apart. How can I tighten the space between the two columns? It behaves as if there's a margin in place for left and right making the columns longer than they need to be to prevent line breaks.

 

function AddRow(FieldName, Label)

{

try

{

if (Field(FieldName))

return "\n <row><cell>" + (Label || FieldName + ":") + "<cell>" +Field(FieldName);

}

catch (e) {}

return "";

}

 

var myTable = '<table columns=2 boxrules="left:Thin,Black" alignment="left" margins="top:5;bottom:5">'

myTable += '\n <column width=3600><column width=6000>'

 

myTable += AddRow("Direct");

myTable += AddRow("Tel");

myTable += AddRow("Fax");

myTable += AddRow("Mobile");

 

myTable += '\n</table>';

return myTable;

Link to comment
Share on other sites

ok, I'm very close to what I'm looking for. I used the code above to come up with a two column table which allowed the contents of each cell to be in alignment however, the cells are spaced too far apart. How can I tighten the space between the two columns? It behaves as if there's a margin in place for left and right making the columns longer than they need to be to prevent line breaks.

 

You would change the column widths to adjust the spacing, although I don't know what the optimal settings would be for you, since I don't know what font or point size you're setting this text in, let alone what the data values are. I can get the columns to line up very closely together without wrapping text here in my little test job, but I don't know why it's not working for you. I'd have to see the job to be able to fully analyze it, but unfortunately that level of investigation is beyond the scope of what I can do in the context of this forum.

 

P.S. Don't be afraid to use [noparse]

[/noparse] tags around code blocks. The forum can help you with this if you click "Go Advanced" and then select the code and hit the # button above the editor window.

Link to comment
Share on other sites

The columns are set up with the smallest width possible without the line breaking. (<column width=3600><column width=6000>

 

There seems to be added spaces before and after each column. This is great in the case that it prevents text from touching the left hand rule line however, it causes a good .25"+ gap between columns.

 

The previous markup is the only rule in my file and applied to a text box with 7pt. Italic type, if that helps. Other than that I'm baffled. I added (alignment="left") to the table but that didn't change anything either.

 

And I thought this would be easy!!!!

Link to comment
Share on other sites

Sticking with the table version, I'm getting different results locally than the version created from the store. The space between columns is still large, however now, the labels want to touch the rule line. (Please see following.)

http://www.acegroupnyc.com/ace_printable/dwb_demo.jpg

 

Again, the source code:

 

function AddRow(FieldName, Label)

{

try

{

if (Field(FieldName))

return "\n <row><cell>" + (Label || FieldName + ":") + "<cell>" +Field(FieldName);

}

catch (e) {}

return "";

}

 

var myTable = '<table columns=2 boxrules="left:Thin,Black" margins="top:5;bottom:5">'

myTable += '\n <column width=3600><column width=5800>'

 

myTable += AddRow("Direct");

myTable += AddRow("Tel");

myTable += AddRow("Fax");

myTable += AddRow("Mobile");

 

myTable += '\n</table>';

return myTable;

Link to comment
Share on other sites

var myTable = '<table columns=2 boxrules="left:Thin,Black" margins="top:5;bottom:5">'

You will need a right value in your margins to move the text to the right.

'<table columns=2 boxrules="left:Thin,Black" margins="top:5;bottom:5;right=50">'

Be aware that right and left margins need 10 times the value to make the same move. If you are ever unsure if you need your values in 10s, 100s, or 1000s just add a zero and see what happens.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...