TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,966
  • Latest: safir45
Stats
  • Total Posts: 195,993
  • Total Topics: 21,324
  • Online today: 368
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 1
  • Guests: 219
  • Total: 220
  • tino

Fix for the "files 0" problem on DL Manager

Started by feline, January 08, 2006, 06:16:11 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

feline

today i have found the files 0 problem within subcat's ..   ::)

first .. the TPdlmanager.php

find this:

//fetch all categories
$context['TPortal']['dlcategories'] = array();
$request = db_query("SELECT * FROM {$tp_prefix}dlmanager WHERE type = 'dlcat'", __FILE__, __LINE__);

if(mysql_num_rows($request)>0){
while ($row = mysql_fetch_assoc($request))
{
$context['TPortal']['dlcategories'][$row['id']] = array(
'id' => $row['id'],
'name' => $row['name'],
'parent' => $row['parent']
);
}
mysql_free_result($request);


then add after:

// get number of files in cats *added by Feline*
$context['TPortal']['dlcatcount']=array();
$request = db_query("SELECT category FROM {$tp_prefix}dlmanager WHERE type = 'dlitem'", __FILE__, __LINE__);
if(mysql_num_rows($request)>0){
while ($row = mysql_fetch_assoc($request))
{
if(isset($context['TPortal']['dlcatcount'][$row['category']]))
$context['TPortal']['dlcatcount'][$row['category']]++;
else
$context['TPortal']['dlcatcount'][$row['category']]=1;
}
mysql_free_result($request);
}


and next find:

// any items to collect?
if(sizeof($cats_allow)>0){
$context['TPortal']['dlcatcount']=array();
$request = db_query("SELECT * FROM {$tp_prefix}dlmanager WHERE type = 'dlitem'", __FILE__, __LINE__);
if(mysql_num_rows($request)>0){
while ($row = mysql_fetch_assoc($request))
{
if(isset($context['TPortal']['dlcatcount'][$row['category']]))
$context['TPortal']['dlcatcount'][$row['category']]++;
else
$context['TPortal']['dlcatcount'][$row['category']]=1;
}
mysql_free_result($request);
}
}


replace this with:

// any items to collect?
if(sizeof($cats_allow)>0){
$context['TPortal']['dlcatcount']=array();
$totalfiles = 0;
$request = db_query("SELECT * FROM {$tp_prefix}dlmanager", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($request)) {
if ($row['type'] == 'dlitem') {
$totalfiles++;
if(isset($context['TPortal']['dlcatcount'][$row['category']]))
$context['TPortal']['dlcatcount'][$row['category']]++;
else
$context['TPortal']['dlcatcount'][$row['category']]=1;
}
elseif($row['category'] == $row['parent'])
$rootcat = $row['id'];
}
mysql_free_result($request);
if (isset($rootcat))
$context['TPortal']['dlcatcount'][$rootcat] = $totalfiles;
}


also, I have mod the TPdlmanager.template.php that empty cat's are not displayed

find:

//show any categories - if not single item mode.
if($context['TPortal']['dlaction']!='item'){
foreach($context['TPortal']['dlcats'] as $dlcat){


add after:
if(isset($context['TPortal']['dlcatcount'][$dlcat['id']]))
{



and find at the end of this block:

echo '
</td>
</tr>';
}


and add after a simple }

I have add pictures ..

Fel

[attachment deleted by admin]

Ray

Thanks feline that looks good -- I'm just amazed of some of the coders that are on this board - thanks to you all

bloc

Thank you. :) that saves me some detective work - and good enhancement too..for 0 files not showing at all, which is logical. ;D

feline

it's a quick fix .. not so performant for database .. i will look later for a better methode ...

Fel

feline

spend my a little bit time Bloc ..
i redesign that part of DL Manager

Fel

elpvn


This website is proudly hosted on Crocweb Cloud Website Hosting.