Posted: 02/22/2004, 5:15 PM |
|
Creating a gallery in CCS 2
Let's suppose you have a table with fields:
id (autonumber)
picfilename (the picture filename)
description
url (where this picture links)
You create a grid using the builder (let's call it gallery_grid) (without Alt rows for now) and select to show all fields exept id
if you check the HTML for the generated grid you 'll see something like this:
<!-- BEGIN Row -->
<tr>
<td>
{picfilename}
</td>
<td>
{description}
</td>
<td>
{url}
</td>
</tr>
<!-- END Row -->
move all variable tags in one cell like this
<td>
{picfilename}
{description}
{url}
</td>
<td>
</td>
<td>
</td>
In the Design mode of CCS Delete all columns exept the one with the labels (id, picfilename etc)
Move <tr> tag before <!-- BEGIN Row --> and </tr> tag after <!-- END Row --> so your html will look like this:
<tr>
<!-- BEGIN Row -->
<td>
{picfilename}
{description}
{url}
</td>
<!-- END Row -->
</tr>
This way when the grid is displayed it will not change row for every record, as a matter of fact it will never change row until end of data...
Create a new label after url label and name it changeline. Change content property from text to html
In the before show events of this label enter this code:
global $gallery_grid;
global $dumcount;
$dumcount++;
if ($dumcount>=4) // 4 is for 4 columns, change it with the number of columns you want to display
{
$gallery_grid->changeline->SetValue("</tr><tr>");
$dumcount=0;
}
else
{
$gallery_grid->changeline->SetValue("");
}
Now go to Code Tab (not events) and just after <?php> type:
global $dumcount;
$dumcount=0;
The pic display thing in the grid is the last part:
change the html of the record between <!-- BEGIN Row --> and <!-- END Row --> as follows:
<!-- BEGIN Row -->
<td>
<a href="{url}" target="_blank"><img src="YourPicFolder/{picfilename}" border="0"></a>
<br>
{description}{changeline}
</td>
<!-- END Row -->
Finish!
It is simpler than it looks, the general idea is this:
- Put all labels in one cell.
- Delete all extra columns and leave only one
- After the data labels put a label that echoes a change row every x times
- Modify the way that field-data shows on screen
You have no need to modify any of the CCS auto-generated code
Now customize as you wish, create thumbs on-the-fly, hyperlink to a details-page, add Alt_rows or whatever.
Hope it will be useful.
Aleister
|