A way for Web authors to sort as they see it on the Web

This tip shows you how to manipulate a string from a DbLookup to be displayed in a browser in a two (or more) column format and sorted counting from left to right, row by row (instead of from top to bottom, splitting the list in two columns).

This is useful when you want your author to decide the sort order of the items - for example if you have a startpage with news highlights in two columns and you want the first item at the top of the first column and the second item at the top of the second column and the third item at the second row of the first column and so on.

 Code: REM "This code makes a list of links to be displayed in a two column format counting items from left to the right and row by row."; REM "Linklist is generated by a lookup. The links are already HTML formated in the view"; view:="your view"; key:="your key"; list:=@DbLookup( "" : "NoCache" ; "" ; view ; key ; 4 ); REM "Some HTML that is reused later on"; tablestart:="<!-- Start contentstable --><TABLE width="100%" cellpadding=5 BORDER=0 CELLSPACING=0 >"; tableend:="</TABLE><!-- End contentstable -->"; dummy:="<IMG SRC="/icons/ecblank.gif" BORDER=0 HEIGHT=1 WIDTH=1 ALT="">"; REM "Number of elements and testing if number is odd or even"; listElements:=@Elements(list); odd:=@Modulo(listElements;2); REM "Linklist plus a dummy item if number is odd "; linklist:=list:@If(odd=1;dummy;""); REM "Generate strings that will be exploded into taglists. The ~ sign is used as separator"; REM " As this is a two column format, a table row start tag and end tag is needed every second item. The separator is used when exploding the string into a list of tags"; separator:="~"; repeatTimes:=@Round(listElements/2)); tagstring1:=@Repeat("<TR><TD>" + separator + "<TD>~"; repeatTimes ) tagstring2:=@Repeat("</TD>" + separator + "</TD></TR>~";repeatTimes) REM "The lists to be concenated with the linklist" REM "The first tag list will look like this: start <TR><TD> : <TD> : <TR><TD> : <TD> : ..."; REM "The second tag list will look like this: </TD> : </TD></TR> : </TD> : </TD></TR> : ..."; taglist1:=@Explode(tagstring1;separator); taglist2:=@Explode(tagstring2;separator); REM "The taglists and linklist put together"; REM "The output list will look like this: <TR><TD> link1 </TD> : <TD> link2 </TD></TR> : <TR><TD> link3 </TD> : <TD> link4 </TD></TR> : ..."; output:= tablestart + @Implode(taglist1 + linklist + taglist2;@NewLine) + tableend; @If(@IsError(templist);"";output)

Dig Deeper on Domino Resources - Part 2

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.




  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...