Forum Moderators: coopster
I making a new site based in a CMS called xoops, is just a Content Management System as phpnuke,postnuke and others..
i want change the way the download section display the download files,
originally every new file is added dinamically below of the previous one,
i want change that to add every new file at right of the previous one, and when it reach the table border follow adding new files below of this first row.
Of course i mean make that having a square template with only the photo and the download link,
is imposible make that with the original rectangular template of course.
in few words, i not need know how to make the square template, thatīs easy.
i need know how to make every new file be added at right of the previous one instead below.
this is a image diagram of the explained above ,check if you not understook my english ;)
this is a part of the viewcat.php file code (where the downloads are listed)
the code between <!-- Start new link loop --> and <!-- End new link loop --> determine the layout of the square, it are cloned every new file is added.
code:
<table width="1" cellspacing="0" cellpadding="0" border="0">
<tr>
<td width="154" align="center" valign="bottom">
<table width="154" cellpadding="5" cellspacing="0" border="0">
</table>
</td>
</tr>
<!-- Start new link loop -->
<td width="154">
<{section name=i loop=$file}>
<tr>
<td width="154" align="center" class="infovip" valign="top">
<table width="1" border="0" cellspacing="0" cellpadding="0">
<tr valign="top">
<!-- JP -->
<b><a href="<{$xoops_url}>/modules/downloadsvip/singlefile.php?lid=<{$file[i].id}>"
/><b><center> <{$file[i].title}><{$file[i].adminlink}></a></center></b>
<!-- JP END -->
<a href="<{$xoops_url}>/modules/downloadsvip/singlefile.php?lid=<{$file[i].id}>"><img src="<{$xoops_url}>/modules/downloadsvip/images/shots/<{$file[i].logourl}>" width="<{$shotwidth}>" alt="" align="center" ></a>
</tr></table>
<{/section}>
<!-- End new link loop -->
</table>
thanks in advance.
grettings.
[edited by: jatar_k at 5:27 am (utc) on July 19, 2003]
[edit reason] no personal urls thanks [/edit]
I understand what you mean, instead of having a verticle list of images/descriptions you want to change it to list 4 per row.
You will have to do a little dynamic table drawing. The way I do it is to set my number of cells, then count my cells as I output in a loop. When I get to the $current_cell == 4 I close the row and start a new row and reset $current_cell = 1. The only thing you need to do is make sure you close all of your cells once you have completed the output.
If the last cell output was 1 then output three empty cells before you close the row, if the last was 2 then 2 empty cells.
That make any sense?
i must say php is not one of my strong abilities.
i still a newbie, i only know how to modify existent scripts,etc but not big thing o make something from 0.
I searched in internet for tutorials and info about the cell funtion,etc without positive results.
the way you mean sounds theorically easy but sincerely i donīt know how to make that :(
grettings
echo "<table>";
while (is_array($linkarray[$counter])) {
if ($current_cell == 1) echo "<tr>";
echo "<td>",your link data goes here,"</td>";
if ($current_cell == 4) {
echo "</tr>";
$current_cell = 1;
} else {
$current_cell++;
}
$counter++;
}
switch ($current_cell) {
case 2:
echo "<td> </td>";
case 3:
echo "<td> </td>";
case 4:
echo "<td> </td>";
echo "</tr>";
break;
}
echo "</table>";
I don't know where the link information is loaded into so the while test is wrong, I assumed they would be loaded into a multidimensional array. It should still give you an idea of how it should work.
i understand how work the code you wrote but i donīt know how to implement in my code,
The CMS Xoops works with smarty templates, them i made a error posting the previus code, the code i wrote was the template code,just i discover that.
The downloadsvip_viewcat.html code (is the template file) is:
<div align="center">
<a href="<{$xoops_url}>/modules/downloadsvip/index.php"><img src="<{$xoops_url}>/modules/downloadsvip/images/logo-en.gif" alt="" /></a>
</div>
<br />
<table width="97%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td align="left">
<table width="100%" cellspacing="1" cellpadding="2" border="0">
<tr>
<td height="18"><div class="info" style="text-align: left;"><b><{$category_path}></b></div></td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="center">
<table width="90%" align="center">
<tr>
<{foreach item=subcat from=$subcategories}>
<td align="left" valign="top"><span class="category"><a href="viewcat.php?cid=<{$subcat.id}>"><{$subcat.title}></a> (<{$subcat.totallinks}>)</span><br /><span class="subcategories"><{$subcat.infercategories}></span></td>
<{if $subcat.count is div by 4}>
</tr><tr>
<{/if}>
<{/foreach}>
</tr>
</table>
<br />
<hr />
<{if $show_links == true}>
<{if $show_nav == true}>
<div><{$lang_sortby}> <{$lang_title}> (<a href="viewcat.php?cid=<{$category_id}>&orderby=titleA"><img src="images/up.gif" border="0" align="middle" alt="" /></a><a href="viewcat.php?cid=<{$category_id}>&orderby=titleD"><img src="images/down.gif" border="0" align="middle" alt="" /></a>) <{$lang_date}> (<a href="viewcat.php?cid=<{$category_id}>&orderby=dateA"><img src="images/up.gif" border="0" align="middle" alt="" /></a><a href="viewcat.php?cid=<{$category_id}>&orderby=dateD"><img src="images/down.gif" border="0" align="middle" alt="" /></a>) <{$lang_rating}> (<a href="viewcat.php?cid=<{$category_id}>&orderby=ratingA"><img src="images/up.gif" border="0" align="middle" alt="" /></a><a href="viewcat.php?cid=<{$category_id}>&orderby=ratingD"><img src="images/down.gif" border="0" align="middle" alt="" /></a>) <{$lang_popularity}> (<a href="viewcat.php?cid=<{$category_id}>&orderby=hitsA"><img src="images/up.gif" border="0" align="middle" alt="" /></a><a href="viewcat.php?cid=<{$category_id}>&orderby=hitsD"><img src="images/down.gif" border="0" align="middle" alt="" /></a>)
<br /><b><{$lang_cursortedby}></b>
</div>
<hr />
<{/if}>
</td>
</tr>
</table>
<br />
<div style="text-align:center;"><{$page_nav}></div>
<table width="1" cellspacing="0" cellpadding="0" border="0">
<tr>
<td width="154" align="center" valign="bottom">
<table width="154" cellpadding="5" cellspacing="0" border="0">
<!-- REMOVIDO 3D -->
</table>
</td>
</tr>
<!-- Start new link loop -->
<td width="154">
<{section name=i loop=$file}>
<tr>
<td width="154" align="center" class="infovip" valign="top">
<table width="1" border="0" cellspacing="0" cellpadding="0">
<tr valign="top">
<!-- JP -->
<b><a href="<{$xoops_url}>/modules/downloadsvip/singlefile.php?lid=<{$file[i].id}>"
/><b><center> <{$file[i].title}><{$file[i].adminlink}></a></center></b>
<!-- JP END -->
<a href="<{$xoops_url}>/modules/downloadsvip/singlefile.php?lid=<{$file[i].id}>"><img src="<{$xoops_url}>/modules/downloadsvip/images/shots/<{$file[i].logourl}>" width="<{$shotwidth}>" alt="" align="center" ></a>
</tr></table>
<!--<{include file="db:downloadsvip_download.html" down=$file[i]}>-->
<{/section}>
<!-- End new link loop -->
</table>
<div style="text-align:center;"><{$page_nav}></div>
<{else}>
<{/if}>
<{include file="db:system_notification_select.html"}>
and the viewcat.php code is:
<?php
// $Id: viewcat.php,v 1.13 2003/03/27 Exp $
// ----------------------------------------------- //
include "header.php";
include_once XOOPS_ROOT_PATH."/class/xoopstree.php";
$xoopsOption['template_main'] = 'downloadsvip_viewcat.html';
$myts =& MyTextSanitizer::getInstance();// MyTextSanitizer object
$mytree = new XoopsTree($xoopsDB->prefix("mydownloads_catvip"),"cid","pid");
$cid = intval($HTTP_GET_VARS['cid']);
include XOOPS_ROOT_PATH."/header.php";
if (isset($HTTP_GET_VARS['show']) && $HTTP_GET_VARS['show']!="") {
$show = intval($HTTP_GET_VARS['show']);
} else {
$show = $xoopsModuleConfig['perpage'];
}
$min = isset($HTTP_GET_VARS['min'])? intval($HTTP_GET_VARS['min']) : 0;
if (!isset($max)) {
$max = $min + $show;
}
if(isset($HTTP_GET_VARS['orderby'])) {
$orderby = convertorderbyin($HTTP_GET_VARS['orderby']);
} else {
$orderby = "title ASC";
}
$pathstring = "<a href='index.php'>"._MD_MAIN."</a> : ";
$pathstring .= $mytree->getNicePathFromId($cid, "title", "viewcat.php?op=");
$xoopsTpl->assign('category_path', $pathstring);
$xoopsTpl->assign('category_id', $cid);
// get child category objects
$arr=array();
$arr=$mytree->getFirstChild($cid, "title");
if ( count($arr) > 0 ) {
$scount = 1;
foreach($arr as $ele){
$sub_arr=array();
$sub_arr=$mytree->getFirstChild($ele['cid'], "title");
$space = 0;
$chcount = 0;
$infercategories = "";
foreach($sub_arr as $sub_ele){
$chtitle=$myts->makeTboxData4Show($sub_ele['title']);
if ($chcount>5){
$infercategories .= "...";
break;
}
if ($space>0) {
$infercategories .= ", ";
}
$infercategories .= "<a href=\"".XOOPS_URL."/modules/downloadsvip/viewcat.php?cid=".$sub_ele['cid']."\">".$chtitle."</a>";
$space++;
$chcount++;
}
$xoopsTpl->append('subcategories', array('title' => $myts->makeTboxData4Show($ele['title']), 'id' => $ele['cid'], 'infercategories' => $infercategories, 'totallinks' => getTotalItems($ele['cid'], 1), 'count' => $scount));
$scount++;
}
}
if ($xoopsModuleConfig['useshots'] == 1) {
$xoopsTpl->assign('shotwidth', $xoopsModuleConfig['shotwidth']);
$xoopsTpl->assign('tablewidth', $xoopsModuleConfig['shotwidth'] + 10);
$xoopsTpl->assign('show_screenshot', true);
$xoopsTpl->assign('lang_noscreenshot', _MD_NOSHOTS);
}
if (!empty($xoopsUser) && $xoopsUser->isAdmin($xoopsModule->mid())) {
$isadmin = true;
} else {
$isadmin = false;
}
$fullcountresult=$xoopsDB->query("SELECT COUNT(*) FROM ".$xoopsDB->prefix("mydownloads_downloadsvip")." WHERE cid=$cid AND status>0");
list($numrows) = $xoopsDB->fetchRow($fullcountresult);
$page_nav = '';
if($numrows>0){
$xoopsTpl->assign('lang_description', _MD_DESCRIPTIONC);
$xoopsTpl->assign('lang_lastupdate', _MD_LASTUPDATEC);
$xoopsTpl->assign('lang_hits', _MD_HITSC);
$xoopsTpl->assign('lang_ratingc', _MD_RATINGC);
$xoopsTpl->assign('lang_email', _MD_EMAILC);
$xoopsTpl->assign('lang_ratethissite', _MD_RATETHISFILE);
$xoopsTpl->assign('lang_reportbroken', _MD_REPORTBROKEN);
$xoopsTpl->assign('lang_tellafriend', _MD_TELLAFRIEND);
$xoopsTpl->assign('lang_modify', _MD_MODIFY);
$xoopsTpl->assign('lang_version' , _MD_VERSION);
$xoopsTpl->assign('lang_subdate' , _MD_SUBMITDATE);
$xoopsTpl->assign('lang_dlnow' , _MD_DLNOW);
$xoopsTpl->assign('lang_category' , _MD_CATEGORYC);
$xoopsTpl->assign('lang_size' , _MD_FILESIZE);
$xoopsTpl->assign('lang_platform' , _MD_SUPPORTEDPLAT);
$xoopsTpl->assign('lang_homepage' , _MD_HOMEPAGE);
$xoopsTpl->assign('lang_comments' , _COMMENTS);
$xoopsTpl->assign('show_links', true);
$q = "SELECT d.lid, d.title, d.url, d.homepage, d.version, d.size, d.platform, d.logourl, d.status, d.date, d.hits, d.rating, d.votes, d.comments, t.description FROM ".$xoopsDB->prefix("mydownloads_downloadsvip")." d, ".$xoopsDB->prefix("mydownloads_textvip")." t WHERE cid=".$cid." AND d.status>0 AND d.lid=t.lid ORDER BY ".$orderby."";
$result = $xoopsDB->query($q,$show,$min);
//if 2 or more items in result, show the sort menu
if($numrows>1){
$xoopsTpl->assign('show_nav', true);
$orderbyTrans = convertorderbytrans($orderby);
$xoopsTpl->assign('lang_sortby', _MD_SORTBY);
$xoopsTpl->assign('lang_title', _MD_TITLE);
$xoopsTpl->assign('lang_date', _MD_DATE);
$xoopsTpl->assign('lang_rating', _MD_RATING);
$xoopsTpl->assign('lang_popularity', _MD_POPULARITY);
$xoopsTpl->assign('lang_cursortedby', sprintf(_MD_CURSORTBY, convertorderbytrans($orderby)));
}
while(list($lid, $dtitle, $url, $homepage, $version, $size, $platform, $logourl, $status, $time, $hits, $rating, $votes, $comments, $description)=$xoopsDB->fetchRow($result)) {
$path = $mytree->getPathFromId($cid, "title");
$path = substr($path, 1);
$path = str_replace("/"," <img src='".XOOPS_URL."/modules/downloadsvip/images/arrow.gif' board='0' alt=''> ",$path);
$rating = number_format($rating, 2);
$dtitle = $myts->makeTboxData4Show($dtitle);
$url = $myts->makeTboxData4Show($url);
$homepage = $myts->makeTboxData4Show($homepage);
$version = $myts->makeTboxData4Show($version);
$size = PrettySize($myts->makeTboxData4Show($size));
$platform = $myts->makeTboxData4Show($platform);
$logourl = $myts->makeTboxData4Show($logourl);
$datetime = formatTimestamp($time,"s");
$description = $myts->makeTareaData4Show($description,0); //no html
$new = newdownloadgraphicvip($time, $status);
$pop = popgraphic($hits);
if ($isadmin) {
$adminlink = '<a href="'.XOOPS_URL.'/modules/downloadsvip/admin/index.php?lid='.$lid.'&fct=mydownloadsvip&op=modDownloadvip"><img src="'.XOOPS_URL.'/modules/downloadsvip/images/editicon.gif" border="0" alt="'._MD_EDITTHISDL.'" /></a>';
} else {
$adminlink = '';
}
if ($votes == 1) {
$votestring = _MD_ONEVOTE;
} else {
$votestring = sprintf(_MD_NUMVOTES,$votes);
}
$xoopsTpl->append('file', array('id' => $lid, 'cid' => $cid, 'rating' => $rating,'title' => $dtitle.$new.$pop,'logourl' => $logourl,'updated' => $datetime,'description' => $description,'adminlink' => $adminlink,'hits' => $hits,'votes' => $votestring, 'comments' => $comments, 'plataform' => $platform,'size' => $size,'homepage' => $homepage,'version' => $version,'category' => $path,'lang_dltimes' => sprintf(_MD_DLTIMES,$hits),'mail_subject' => rawurlencode(sprintf(_MD_INTFILEFOUND,$xoopsConfig['sitename'])),'mail_body' => rawurlencode(sprintf(_MD_INTFILEFOUND,$xoopsConfig['sitename']).': '.XOOPS_URL.'/modules/downloadsvip/singlefile.php?cid='.$cid.'&lid='.$lid)));
}
$orderby = convertorderbyout($orderby);
//Calculates how many pages exist. Which page one should be on, etc...
$downpages = ceil($numrows / $show);
//Page Numbering
if ($downpages!=1 && $downpages!=0) {
$prev = $min - $show;
if ($prev>=0) {
$page_nav .= "<a href='viewcat.php?cid=$cid&min=$prev&orderby=$orderby&show=$show'><b><u>«</u></b></a> ";
}
$counter = 1;
$currentpage = ($max / $show);
while ( $counter<=$downpages ) {
$mintemp = ($show * $counter) - $show;
if ($counter == $currentpage) {
$page_nav .= "<b>($counter)</b> ";
} else {
$page_nav .= "<a href='viewcat.php?cid=$cid&min=$mintemp&orderby=$orderby&show=$show'>$counter</a> ";
}
$counter++;
}
if ( $numrows>$max ) {
$page_nav .= "<a href='viewcat.php?cid=$cid&min=$max&orderby=$orderby&show=$show'>";
$page_nav .= "<b><u>»</u></b></a>";
}
}
}
$xoopsTpl->assign('page_nav', $page_nav);
include XOOPS_ROOT_PATH."/modules/downloadsvip/footer.php";
?>
sorry about all the confusion i had and over all the things sorry for take so much of your valious time man.
But im trying to solve this problem since almost 1 month ago, and the only place where i get help was in this wonderfull discusion board,only here.
if you need some other details about the files,etc plz ask me.
thanks in advance.
grettings