Main
Index
Search
Posts
Who's
Online
Log
In

Home: Products: CMS Builder:
Listings in 2 columns

 

 


WEVOLUTIONS
User

Nov 6, 2008, 8:35 PM

Post #1 of 7 (2057 views)
Shortcut
Listings in 2 columns Can't Post

I know about the line of code to add to get your listings into 2 columns but I am confused as to where exactly to put it.

I think this is the code I need to use. Please correct me if I am wrong.


Code
<?php $maxCols=2; if (@++$count % $maxCols == 0): ?></tr><tr><?php endif; ?>



(This post was edited by WEVOLUTIONS on Nov 7, 2008, 9:00 PM)


Dave
Staff / Moderator


Nov 10, 2008, 3:22 PM

Post #2 of 7 (2017 views)
Shortcut
Re: [WEVOLUTIONS] Listings in 2 columns [In reply to] Can't Post

Hi wevolutions.

The first step is to create a plain html mockup of how you want your 2 column layout to look. Usually this is done with a 2 column table. If that's the case then the code would typically look something like this:


Code
<table border="1"> 
<tr>

<?php foreach ($records as $record): ?>

<td> ... display record here ... </td>

<?php $maxCols=2; if (@++$count % $maxCols == 0): ?></tr><tr><?php endif; ?>
<?php endforeach ?>

</tr>
</table>


Hope that helps!

Dave Edis - Senior Developer
interactivetools.com
 


WEVOLUTIONS
User

Nov 10, 2008, 6:15 PM

Post #3 of 7 (2014 views)
Shortcut
Re: [Dave] Listings in 2 columns [In reply to] Can't Post

Here is the html mock up code. I have a few table cells with images and information in other cells so I am not sure where to insert the code for it to work.


Code
<table width="544" border="0" cellspacing="0" cellpadding="0"> 
<tr height="1">
<td colspan="3" valign="top" bgcolor="#d9dadc" width="544" height="1"></td>
</tr>
<tr height="120">
<td valign="top" width="175" height="120"><?php foreach ($record['main_photo'] as $upload): ?><?php if ($upload['hasThumbnail']): ?><a href="<?php echo $record['_link'] ?>#top"><img src="<?php echo $upload['thumbUrlPath'] ?>" width="160" height="120" border="1" alt="" hspace="5" vspace="5" /></a><?php elseif ($upload['isImage']): ?><img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" /><?php else: ?><a href="<?php echo $upload['urlPath'] ?>">Download <?php echo $upload['filename'] ?></a><?php endif ?><?php break; ?><?php endforeach ?><br />
</td>
<td valign="top" width="149" height="120"><br />
<font size="4" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular"><b><a href="<?php echo $record['_link'] ?>#top"><?php echo $record['main_id'] ?></a></b></font><font size="3" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular"><b><br />
</b></font><font size="2" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular">
<table width="138" border="0" cellspacing="0" cellpadding="0">
<tr height="20">
<td align="left" valign="top" width="45" height="20"><font size="2" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular">Make:</font></td>
<td align="left" valign="top" width="93" height="20"><font size="2" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular"><b><?php echo $record['make_of_car'] ?></b></font></td>
</tr>
<tr height="20">
<td align="left" valign="top" width="45" height="20"><font size="2" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular">Model:</font></td>
<td align="left" valign="top" width="93" height="20"><font size="2" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular"><b><?php echo $record['model_of_car'] ?></b></font></td>
</tr>
<tr height="20">
<td align="left" valign="top" width="45" height="20"><font size="2" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular">Year:</font></td>
<td align="left" valign="top" width="93" height="20"><font size="2" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular"><b><?php echo $record['year_of_manufacture'] ?></b></font></td>
</tr>
</table>
</font></td>
<td valign="top" width="220" height="120"><br />
<font size="4" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular"><b><?php echo $record['license_plate_no'] ?></b></font><font size="3" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular"><b><br />
</b></font>
<table width="220" border="0" cellspacing="0" cellpadding="0">
<tr height="20">
<td align="left" valign="top" width="86" height="20"><font size="2" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular">Asking Price:</font></td>
<td align="left" valign="top" width="134" height="20"><font size="2" color="red" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular"><b><?php echo $record['asking_price'] ?></b></font></td>
</tr>
<tr height="20">
<td align="left" valign="top" width="86" height="20"><font size="2" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular">Contact No.:</font></td>
<td align="left" valign="top" width="134" height="20"><font size="2" color="black" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular"><b><?php echo $record['contact_phone_nos'] ?></b></font></td>
</tr>
<tr height="20">
<td align="left" valign="top" width="86" height="20"><font size="2" face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular"><a href="<?php echo $record['_link'] ?>#top">More Details</a></font></td>
<td align="left" valign="top" width="134" height="20"></td>
</tr>
</table>
</td>
</tr>
<tr height="1">
<td colspan="3" valign="top" bgcolor="#d9dadc" width="544" height="1"></td>
<?php endforeach; ?></tr>
</tr>
</table>



Dave
Staff / Moderator


Nov 11, 2008, 3:41 PM

Post #4 of 7 (1992 views)
Shortcut
Re: [WEVOLUTIONS] Listings in 2 columns [In reply to] Can't Post

Hi wevolutions,

Do you want just the image on the left and the content on the right? Or two columns of that?

You could pretty much just put your foreach around that whole table.

What I recommend is starting with a much simpler table layout with borders on and just one field. Then building up from there.

Dave Edis - Senior Developer
interactivetools.com
 


Christopherb
User

Mar 21, 2009, 9:08 PM

Post #5 of 7 (1381 views)
Shortcut
Re: [Dave] Listings in 2 columns [In reply to] Can't Post

Hi Dave,

I tried altering that code for displaying thumbnail images in 2 columns per row with no luck.

How would I change the following code to generate 2 columns per row?


Code
 <!-- Upload Fields: num, createdTime, tableName, fieldName, recordNum, preSaveTempId, filePath, filename, extension, thumbFilePath, isImage, hasThumbnail, urlPath, width, height, thumbUrlPath, thumbWidth, thumbHeight, info1, info2, info3, info4, info5 --> 
<?php foreach ($training_centerRecord['photo'] as $upload): ?>
<?php if ($upload['hasThumbnail']): ?>
<img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /><br/> <?php elseif ($upload['isImage']): ?>
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" /><br/>

<?php else: ?>
<a href="<?php echo $upload['urlPath'] ?>">Download <?php echo $upload['filename'] ?></a><br/>

<?php endif ?>
<?php endforeach ?>



Thanks,



Chris


Christopherb
User

Mar 23, 2009, 8:49 AM

Post #6 of 7 (1286 views)
Shortcut
Re: [Christopherb] Listings in 2 columns [In reply to] Can't Post

It was late, I missed an endif...

If anyone needs the code example for a 3 column image display layout with links created for larger images and downloads, here it is...


Code
   

<table border="1"> <tr> <?php foreach ($training_centerRecord['photo'] as $upload): ?>
<?php if ($upload['hasThumbnail']): ?>
<td>
<a href="<?php echo $upload['urlPath'] ?>"> <img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /> </a>
</td>
<?php $maxCols=3; if (@++$count % $maxCols == 0): ?></tr><tr><?php endif; ?>
<?php elseif ($upload['isImage']): ?>
<td colspan="2">
<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>" height="<?php echo $upload['height'] ?>" alt="" /><br/>

<?php else: ?>
<td colspan="2"> <a href="<?php echo $upload['urlPath'] ?>">Download <?php echo $upload['filename'] ?></a><br/>
</td>
<?php endif ?>
<?php endforeach ?> <td>&nbsp;</td>
</tr>
</table>



(This post was edited by Christopherb on Mar 23, 2009, 12:40 PM)


Dave
Staff / Moderator


Mar 23, 2009, 12:09 PM

Post #7 of 7 (1279 views)
Shortcut
Re: [Christopherb] Listings in 2 columns [In reply to] Can't Post

Chris,

Glad you got it working! Thanks for posting back. :)

Dave Edis - Senior Developer
interactivetools.com