vibez
Karma: -1
|
Modifying Top Uploaders module - 2006/10/12 23:29
I need to help. I have modified the top uploaders module to look in the fileversion field.
The only problem is that obviously if that column is blank in the database table it can end up generating lists like this
(8899) version 1 (339) version 2 (125) version 3 (99)
Notice the top result is blank.
Basically, instead of the module returning the bank result, I want it return the words "unknown"
Kind of like this
Code: | if ($name) { echo "$name"; }
else { echo "unknown"; }
|
But for whatever reason, that code is not working for me. So I need some basic php code help.
Code: | <?php
/**
* FileName: mod_remositoryartists.php
* Date: 20 June 2006
*
License: GNU General Public License
* Script Version #: 3.25
* ReMOSitory
Version #: 3.20 or above
* MOS Version #: 4.5 or above
* Author: Martin
Brampton - martin@remository.com (http://www.remository.com)
* Copyright: Martin
Brampton 2006
**/
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
global $mosConfig_absolute_path, $mosConfig_absolute_path, $my;
require_once ($mosConfig_absolute_path.'/components/com_remository/remository.utilities.php');
/*********************Configuration*********************/
// Max number of entries to show
$max = remositoryUtilities::realiro_get_module_parm($params,'max',5 );
$max = max($max,1);
/*******************************************************/
include('components/com_remository/com_remository_settings.php');
function topArtists ($max) {
global $database;
$sql = "SELECT COUNT(id) AS uploads, fileversion AS name FROM aliro_downloads_files WHERE published=1
GROUP BY fileversion ORDER BY uploads DESC LIMIT $max";
$database->setQuery($sql);
$uploaders = $database->loadObjectList();
if ($uploaders) return $uploaders;
else return array();
}
$tabclass_arr=explode(",",$tabclass);
$name = $uploader->name;
if ($name) { echo "$name"; }
else { echo "unknown"; }
// Top Uploaders
$people = topArtists ($max);
$content = remositoryUtilities::realiro_module_CSS ();
$tabcnt = 0;
foreach ($people as $uploader) {
$class = $tabclass_arr[$tabcnt];
$content .= "<tr><td width='20%' align='left' ><b>";
$content .= $uploader->name."</b></td><td align='right'><b>";
$content .= $uploader->uploads;
$content .= "</B></td></tr>n";
if ($tabcnt == 1){
$tabcnt = 0;
} else {
$tabcnt++;
}
}
$content .= "</table>n";
?>
|
Post edited by: vibez, at: 2006/10/12 18:29
|