Revision [8901]

This is an old revision of ArrayToColumns made by JavaWoman on 2005-06-07 09:41:36.

 

Generating a List from an Array


See also:
This page presents new code for the WikkaCore Wikka Core to generate well-structured lists from an array of items to be presented.

Why?


In many cases we get an array back from some procedure and want to display the result in the form of a list. In several places in the Wikka code this now happens "manually" in that each uses its own code to build the HTML to present the list. This is not only inefficient, but also leads to inconsistent and sometimes not even well-structured code. (Example: the TextSearch produces a numbered list of matching page names - but it is not only not sorted, it is not even an ordered list.)

Using a standard way to generate lists is more efficient, can ensure consistent code and makes it easier to write methods that need some kind of list as output.

How?


Two separate methods were written to make it easy to generate well-structured lists with 'hooks' for styling: the first does nothing but generate a list from an array (with an id); the second wraps that in a bit of code with a heading and a bit of text instead of the list if the array happens to be empty.

The Code



When and where to use



CategoryDevelopmentCore
There is one comment on this page. [Display comment]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki