The following code produces a page which displays photo albums. But they are displayed one on top of the other. I'm trying to figure out how to make them be displayed TWO per row, next to each other instead. The below code is the PHP source, and after that the template file. It contains a lot of HTML which is why I posted it here and I'm sure the solution is editing the template file.
Any help would be greatly appreciated as this seems beyond my current understanding.
---browse_albums.php---
and the template file:
---browse_albums.tpl---
Any help would be greatly appreciated as this seems beyond my current understanding.
---browse_albums.php---
Code:
<?php
/* $Id: browse_albums.php 16 2009-01-13 04:01:31Z john $ */
$page = "browse_albums";
include "header.php";
// DISPLAY ERROR PAGE IF USER IS NOT LOGGED IN AND ADMIN SETTING REQUIRES REGISTRATION
if( !$user->user_exists && !$setting['setting_permission_album'] )
{
$page = "error";
$smarty->assign('error_header', 639);
$smarty->assign('error_message', 656);
$smarty->assign('error_submit', 641);
include "footer.php";
}
// PARSE GET/POST
if(isset($_POST['p'])) { $p = $_POST['p']; } elseif(isset($_GET['p'])) { $p = $_GET['p']; } else { $p = 1; }
if(isset($_POST['s'])) { $s = $_POST['s']; } elseif(isset($_GET['s'])) { $s = $_GET['s']; } else { $s = "album_datecreated DESC"; }
if(isset($_POST['v'])) { $v = $_POST['v']; } elseif(isset($_GET['v'])) { $v = $_GET['v']; } else { $v = 0; }
// ENSURE SORT/VIEW ARE VALID
if($s != "album_datecreated DESC" && $s != "album_dateupdated DESC") { $s = "album_dateupdated DESC"; }
if($v != "0" && $v != "1") { $v = 0; }
// SET WHERE CLAUSE
$where = "CASE
WHEN se_albums.album_user_id='{$user->user_info[user_id]}'
THEN TRUE
WHEN ((se_albums.album_privacy & @SE_PRIVACY_REGISTERED) AND '{$user->user_exists}'<>0)
THEN TRUE
WHEN ((se_albums.album_privacy & @SE_PRIVACY_ANONYMOUS) AND '{$user->user_exists}'=0)
THEN TRUE
WHEN ((se_albums.album_privacy & @SE_PRIVACY_FRIEND) AND (SELECT TRUE FROM se_friends WHERE friend_user_id1=se_albums.album_user_id AND friend_user_id2='{$user->user_info[user_id]}' AND friend_status='1' LIMIT 1))
THEN TRUE
WHEN ((se_albums.album_privacy & @SE_PRIVACY_SUBNET) AND '{$user->user_exists}'<>0 AND (SELECT TRUE FROM se_users WHERE user_id=se_albums.album_user_id AND user_subnet_id='{$user->user_info[user_subnet_id]}' LIMIT 1))
THEN TRUE
WHEN ((se_albums.album_privacy & @SE_PRIVACY_FRIEND2) AND (SELECT TRUE FROM se_friends AS friends_primary LEFT JOIN se_users ON friends_primary.friend_user_id1=se_users.user_id LEFT JOIN se_friends AS friends_secondary ON friends_primary.friend_user_id2=friends_secondary.friend_user_id1 WHERE friends_primary.friend_user_id1=se_albums.album_user_id AND friends_secondary.friend_user_id2='{$user->user_info[user_id]}' AND se_users.user_subnet_id='{$user->user_info[user_subnet_id]}' LIMIT 1))
THEN TRUE
ELSE FALSE
END";
// ONLY MY FRIENDS' ALBUMS
if($v == "1" && $user->user_exists) {
// SET WHERE CLAUSE
$where .= " AND (SELECT TRUE FROM se_friends WHERE friend_user_id1='{$user->user_info['user_id']}' AND friend_user_id2=se_albums.album_user_id AND friend_status=1)";
}
// CREATE ALBUM OBJECT
$album = new se_album();
// GET TOTAL ALBUMS
$total_albums = $album->album_total($where);
// MAKE ENTRY PAGES
$albums_per_page = 20;
$page_vars = make_page($total_albums, $albums_per_page, $p);
// GET ALBUM ARRAY
$album_array = $album->album_list($page_vars[0], $albums_per_page, $s, $where);
// ASSIGN SMARTY VARIABLES AND DISPLAY ALBUMS PAGE
$smarty->assign('albums', $album_array);
$smarty->assign('total_albums', $total_albums);
$smarty->assign('p', $page_vars[1]);
$smarty->assign('maxpage', $page_vars[2]);
$smarty->assign('p_start', $page_vars[0]+1);
$smarty->assign('p_end', $page_vars[0]+count($album_array));
$smarty->assign('s', $s);
$smarty->assign('v', $v);
include "footer.php";
?>
and the template file:
---browse_albums.tpl---
Code:
{include file='header.tpl'}
{* $Id: browse_albums.tpl 2 2009-01-10 20:53:09Z john $ *}
<div class='page_header'>{lang_print id=1000127}</div>
<div style='padding: 7px 10px 7px 10px; background: #F2F2F2; border: 1px solid #BBBBBB; margin: 10px 0px 10px 0px; font-weight: bold;'>
<table cellpadding='0' cellspacing='0'>
<tr>
<td>
{lang_print id=1000128}
</td>
<td>
<select style='background-color:#CCCCCC' class='small' name='v' onchange="window.location.href='browse_albums.php?s={$s}&v='+this.options[this.selectedIndex].value;">
<option style='background-color:#CCCCCC' value='0'{if $v == "0"} SELECTED{/if}>{lang_print id=1000129}</option>
{if $user->user_exists}<option value='1'{if $v == "1"} SELECTED{/if}>{lang_print id=1000130}</option>{/if}
</select>
</td>
<td style='padding-left: 20px;'>
{lang_print id=1000131}
</td>
<td>
<select style='background-color:#CCCCCC' class='small' name='s' onchange="window.location.href='browse_albums.php?v={$v}&s='+this.options[this.selectedIndex].value;">
<option style='background-color:#CCCCCC' value='album_dateupdated DESC'{if $s == "album_dateupdated DESC"} SELECTED{/if}>{lang_print id=1000132}</option>
<option style='background-color:#CCCCCC' value='album_datecreated DESC'{if $s == "album_datecreated DESC"} SELECTED{/if}>{lang_print id=1000133}</option>
</select>
</td>
</tr>
</table>
</div>
{* DISPLAY PAGINATION MENU IF APPLICABLE *}
{if $maxpage > 1}
<div style='text-align: center; padding-bottom: 10px;'>
{if $p != 1}<a href='browse_albums.php?s={$s}&v={$v}&p={math equation='p-1' p=$p}'>« {lang_print id=182}</a>{else}« {lang_print id=182}{/if}
|
{if $p_start == $p_end}
<b>{lang_sprintf id=184 1=$p_start 2=$total_albums}</b>
{else}
<b>{lang_sprintf id=185 1=$p_start 2=$p_end 3=$total_albums}</b>
{/if}
|
{if $p != $maxpage}<a href='browse_albums.php?s={$s}&v={$v}&p={math equation='p+1' p=$p}'>{lang_print id=183} »</a>{else}{lang_print id=183} »{/if}
</div>
{/if}
<div>
{section name=album_loop loop=$albums}
{* SET ALBUM COVER *}
{if $albums[album_loop].album_cover_id == 0}
{assign var='album_cover_src' value='./images/icons/folder_big.gif'}
{else}
{* IF IMAGE, GET THUMBNAIL *}
{if $albums[album_loop].album_cover_ext == "jpeg" || $albums[album_loop].album_cover_ext == "jpg" || $albums[album_loop].album_cover_ext == "gif" || $albums[album_loop].album_cover_ext == "png" || $albums[album_loop].album_cover_ext == "bmp"}
{assign var='album_cover_dir' value=$url->url_userdir($albums[album_loop].album_author->user_info.user_id)}
{assign var='album_cover_src' value="`$album_cover_dir``$albums[album_loop].album_cover_id`_thumb.jpg"}
{* SET THUMB PATH FOR AUDIO *}
{elseif $albums[album_loop].album_cover_ext == "mp3" || $albums[album_loop].album_cover_ext == "mp4" || $albums[album_loop].album_cover_ext == "wav"}
{assign var='album_cover_src' value='./images/icons/audio_big.gif'}
{* SET THUMB PATH FOR VIDEO *}
{elseif $albums[album_loop].album_cover_ext == "mpeg" || $albums[album_loop].album_cover_ext == "mpg" || $albums[album_loop].album_cover_ext == "mpa" || $albums[album_loop].album_cover_ext == "avi" || $albums[album_loop].album_cover_ext == "swf" || $albums[album_loop].album_cover_ext == "mov" || $albums[album_loop].album_cover_ext == "ram" || $albums[album_loop].album_cover_ext == "rm"}
{assign var='album_cover_src' value='./images/icons/video_big.gif'}
{* SET THUMB PATH FOR UNKNOWN *}
{else}
{assign var='album_cover_src' value='./images/icons/file_big.gif'}
{/if}
{/if}
<div class='albums_browse_item' style='width: 415px; float: left;'>
<table cellpadding='0' cellspacing='0'>
<tr>
<td style='vertical-align: top;'>
<a href='{$url->url_create('album', $albums[album_loop].album_author->user_info.user_username, $albums[album_loop].album_id)}'><img src='{$album_cover_src}' border='0' width='100' height='100'></a>
</td>
<td style='vertical-align: top; padding-left: 10px;'>
<div style='font-weight: bold; font-size: 10pt;'><a href='{$url->url_create('album', $albums[album_loop].album_author->user_info.user_username, $albums[album_loop].album_id)}'>{$albums[album_loop].album_title|truncate:30:"...":true}</a></div>
<div class='album_browse_date'>
{assign var='album_dateupdated' value=$datetime->time_since($albums[album_loop].album_dateupdated)}{capture assign="updated"}{lang_sprintf id=$album_dateupdated[0] 1=$album_dateupdated[1]}{/capture}
{lang_sprintf id=1000172 1=$albums[album_loop].album_files} - {lang_sprintf id=1000124 1=$updated 2=$url->url_create("profile", $albums[album_loop].album_author->user_info.user_username) 3=$albums[album_loop].album_author->user_displayname}
</div>
<div style='margin-top: 10px;'>{$albums[album_loop].album_desc|truncate:75:"...":true}</div>
</td>
</tr>
</table>
</div>
{cycle values=",<div style='clear: both; height: 10px;'></div>"}
{/section}
</div>
{include file='footer.tpl'}