[Web4lib] outputting a pre formatted list from a database to a
web page
Tyson Tate
tysontate at gmail.com
Tue Aug 22 14:55:27 EDT 2006
On 8/22/06, John Fitzgibbon <jfitzgibbon at galwaylibrary.ie> wrote:
> In one of the fields, I now need to add a list consisting of two
> columns. I will have to store the HTML tags with the list in the Access
> field. However, I don't want to use the div, or table element because
> frequently, the field is output to a web page where it is enclosed by
> span tags. Block elements are not allowed within inline elements such as
> span.
So you want a block of text inside of a span element? If you're trying
to do this, something is probably wrong with your HTML structure.
Think about it semantically - are you sure this is the only way to do
it? Becuase the semantic way to display a table of data is to use a
<table> (of course). Doing so will save you lots of headaches with
what I'm going to propose below.
> My plan is to store it in Access along with the <pre> tag and, thus,
> output it using the <pre> tag having each column separated by a tab. The
> problem with this is that the data in column one is sometimes quite long
> forcing the data in column two further right like so.
>
> <pre>
> Inns or Hotels 1.
> Public Houses 31.
> Mail Coach Offices 2.
> Dispensary 1.
> Trades - townland Callings -
> Surgeons 2.
> Apothecaries 2.
> Wine and Spirit Merchants 3.
> Grocers and Wine Merchants 3.
> Spirit Merchants, Grocers and Ironmongers 4.
> Tobacco Manufacturers 1.
> </pre>
You'll have to write a server-side script that runs through the items
and determines the longest one (in this case, "Spirit Merchants,
Grocers and Ironmongers"). Take the length of that, add a buffer (say,
four spaces), and then run through and output each line like so:
(python-ish pseudocode)
for line in lines:
print line.title + (" " * (len(longestline) - len(line.title) +
buffer) + line.number + "\n"
Catch the idea?
Hope this helps,
Tyson
More information about the Web4lib
mailing list