We tried something like this in the spring. If the paragraphs are uniform in length you can get columns roughly balanced - but never with a high degree of certainty.

We also knew our subscribers would be printing out the copy, and that's where we gave up on two column layout, as we had no control over the sheet size, font size, etc. If an article extended over two pages, you had to read the first colum to the bottom, turn the page and keep reading to the end of the column, then flip back and start reading the second column.

I suppose one could get closer, but look at the desktop publishing programs - apart from FrameMaker, you have to flow and place text by hand. To do it we'd be counting lines, adjusting for heads and bylines, and hoping, hoping, hoping it would not look too disgraceful.

So we bailed out - the subscriber could read it online, with a decent line lenght in a Flash movie, or accept "typewriter like" printout extending across the page. What made that decision easier was a survey which indicated that over 90% of subscribers read it on line and did not print it.

Cheers - Miles Thompson


At 07:10 PM 8/26/2003 +0200, Dynamical.biz wrote:
Hi, I've been dealing withs this question:

I've never seen dynamical balanced text in two colums in a web so this the
challenge.

html formated text is stored in a database, conetion and placed into a
variable i.e.:
$text = "<P><IMG alt="labordeta" hspace=3
src="http://www.lamundial.net/img/labordeta.jpg"; align=left
border=0><EM>efe.Zaragoza.</EM> El parlamentario.</P><P>Some more text
tranquilo simplenente trabajando.</P>"; ... some more paragrphs just like
newspaper articles.

the first idea is this:
1. count the total characters in $text string so we can guess juts the half
2. getting into $tx1 variable the fisrt half
3. count the total characters in $tx1 till the fisrt "</p>" STARTING from
the END to the BEGUINING of $tx1
4. getting into $col1 the fist part
5. getting into $col2 the rest
6. render the text in a table

//CODE
1. $half = floor(strlen($texto)/2);
2. $tx1 = substr($text,0,$half);
3. $first_P = strrpos($tx1,"</P>");

4. $col1 = substr($text,0,$first_P);
5. $col2 = substr($text,$first_P);
6.
<table>
  <tr>
    <td><?= $col1 ?></td>
    <td><?= $col2 ?></td>
  </tr>
</table>

PROBLEMS
easy to know the middle point of a string but we have html code so easy to
break it badly, something like:
<IMG hspace=3 src="ht <-|-> tp://www.lamundial.net/img/img.jpg"> so this is
why the </p> idea.

If there is a large paragrph in the middle of the whole text the columns the
two columns are not so nice balanced, this is why I ask the people writing
articles for my web trying to avoid looooong ones. They use HTMLAREA
http://www.interactivetools.com/products/htmlarea/ from Interactive tools so
the html is not done by hand.

anyway just in case there is no way to correctly balance the text I let the
writer the "1 colum / 2 colums" as an option so the traditional 1 colum (no
colums) is always available. they can display the final render os the
article as they save it when writing so the decide.

this is working at most of the articles in
http://www.lamundial.net

i.e.:
http://www.lamundial.net/home.php?pg=article&idart=124
http://www.lamundial.net/home.php?pg=article&idart=121
http://www.lamundial.net/home.php?pg=article&idart=118

the text balancing is working quite nice


any other idea? thanks



aniceto lópez
DYNAMICAL.BIZ
web development
host services

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to