Ask the Expert

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.

This was first published in October 2003

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: