Problem solve Get help with specific problems with your technologies, process and projects.

Ordering pictures on a page from a Web-based DB

Hi, I am trying to do a photo gallery for my company. I have created an existing Web-based database to form it. However, I am stuck in trying to order the pictures horizontally and vertically in a page (i.e., 3x3). This is possible in PHP, but I just cannot figure out how to do it in Domino. I hope that you can help.
It can be done using pass-thru HTML. You can either write a LotusScript agent to generate the page HTML using Print statements or use clever macro coding on a form to generate the HTML. With Notes 6, you can also use Domino JSP tags -- refer to "Programming: JSP tag libraries" in the Domino Designer help.

Exactly how to do it depends on how you're storing the pictures. Since you did say 3x3, I'm assuming that you'll have a set of Notes documents, with one file attachment per document, and when they go to a particular view, you'd like to display the images in a 3x3 array rather than in rows like a normal view. If there are more than nine images, you'd like to have next and previous buttons.

@If(@Attachments = 0 | 
@isDocBeingEdited; @Return(""); ""); 
picsPerRow := 3; 
pics := "<IMG SRC="" +
 @Text(@DocumentUniqueID) + "/
$FILE/" + 
@AttachmentNames + "" ALT="" + @AttachmentNames + "">"; picCt := @Elements(pics); rowCt := @Integer((picCt + picsPerRow - 1) / picsPerRow); before := @Explode(@Repeat ("<TR><TD>;<TD>;<TD>;"; rowCt); ";"); after := @Explode(@Repeat("</TD>; </TD>;</TD></TR>;"; rowCt); ";"); pics := @If(@Elements(pics) < @Elements(before); pics : " "; pics); "<TABLE>" + @Implode(before + pics + after; "") + "</TABLE>"
I've left out all the style tags and column width controls and so on, but you should get the basic idea from this. If you have the attachments in various documents and want to display the "view" of images, you could use a formula like this, but read the "pics" value using an @DbLookup instead of using @AttachmentNames.

The above will display all the pictures on one page, three columns by however many rows it takes. If you're more interested in showing 3x3 with a Next Page control, then you could use URL arguments to control which is the first image displayed. The formula could use the Query_String CGI variable to find out what the starting number is, take a relevant subset of the "pics" list and show just that.

Alternately, if you have a view that lists picture attachment documents, one attachment per document, you could have the view column formula display the HTML for the image display. A $$ViewTemplate page could use passthru JavaScript code with the embedded view as part of a JavaScript variable initializer. Then use document.write to output the HTML you desire.

Dig Deeper on Lotus Notes Domino Formula Language

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

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 ...