[thelist] Multiple column text?

David Siedband technique at oceanicsky.com
Thu Mar 10 03:58:58 CST 2005

On Mar 9, 2005, at 2:15 PM, Brooking, John wrote:

[ ... ]

> In one section of their spec, they have some text broken down into two
> side-by-side columns, as one would find in a newspaper.

[ ... ]

>    My only other idea, and the only other one mentioned in the pages I
> found, is to just manually split the text into two side-by-side text
> areas. This means the user who will ultimately maintain the page (not
> me) will update it by editing two separate text elements and putting
> half of the text into each. Yucky, but I don't have any better ideas.

I would suggest against splitting this content into two fields, and 
providing two textarea fields for editing.  This is likely to confuse 
people and you're assuming they will take the time/effort to split the 
content in the right place.

Here's the approach I would pursue:
Think of your text as a string, n characters in length.  First throw a 
len() function on that string to get the total number of characters.  
Then, divide by two and round to the nearest integer to find the middle 
character (rounding handles strings of non-even lengths), read forward 
or backward to find the closest space character (so you don't chop your 
content in the middle of a word).  Now you have a character number in 
the string to do your split into two sub strings; Plug these into your 
columns.  The two columns may not be of exactly even height in your 
layouts due to differences in word length affecting word-wrap, but they 
will be pretty close.

David Siedband

More information about the thelist mailing list