Members   Search      Help    Register    Login    Home
Home » Support Forums for PMBT 2.X » Feature Request for 2.X » subcategories mod
subcategories mod [message #3853] Sun, 11 April 2010 15:18 Go to next message
TryHarder is currently offline TryHarder  Australia
Messages: 18
Registered: April 2010
Leecher
hi guys has anyone got a subcat mod the can post please
Re: subcategories mod [message #3855 is a reply to message #3853] Sun, 11 April 2010 16:14 Go to previous messageGo to next message
joeroberts is currently offline joeroberts  United States
Messages: 1971
Registered: June 2006
Location: U.S.A
Releaser
Da HacKer
In your data base replace your torrent_categories with
CREATE TABLE IF NOT EXISTS `torrent_categories` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `name` varchar(30) NOT NULL default '',
  `sort_index` int(10) unsigned NOT NULL default '0',
  `image` varchar(255) NOT NULL default '',
  `parent_id` mediumint(5) NOT NULL default '-1',
  `tabletype` tinyint(2) unsigned NOT NULL default '1',
  PRIMARY KEY  (`id`),
  UNIQUE KEY `name` (`name`),
  KEY `sort_index` (`sort_index`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=0 ;

Make sure you alter the prefix torrent_ to what you used
Now Open include/functions.php and add
function genrelist2() {
        global $db, $db_prefix;

 $row = $db->sql_query("SELECT id, name, image, parent_id, tabletype FROM ".$db_prefix."_categories ORDER BY name");

 while ($mysqlcats = $db->sql_fetchrow($row))
 $allcats[] = $mysqlcats;

 $allcats2 = $allcats;
 
 $i = 0;
 
 foreach ($allcats as $cat)
 {

 if ($cat[parent_id] == -1) 
 {

 $cats[] = $cat;
 $j = 0;
 foreach ($allcats2 as $subcat)
 {

 if ($cat[id] == $subcat[parent_id]) {

 //Subcategories
 $cats[$i]['subcategory'][] = $subcat;

 //Subcategories add parenttabletype
 $cats[$i]['subcategory'][$j]['parenttabletype'] = $cat['tabletype'];

 //Subcategories add idtabletype
 $cats[$i]['subcategory'][$j]['idtabletype'] = $subcat['id'].$subcat['tabletype'];

 //Subcategories description
 $cats[$i]['subcategory'][$j]['description'] = $cat['name']."->".$subcat['name'];

 //All link array for cats
 $cats[$i]['categories'] .= "cats$cat[tabletype][]=$subcat[id]&";

 $j++;
 }
 }
 
 //All link for cats
 $cats[$i]['categories'] = substr($cats[$i]['categories'],0,-5);
 $i++;

 }

 }

 return $cats;

}

function categories_table($cats, $wherecatina, $linkpage = '', $display = 'block')
{
global $theme;

 $html = "";

 $html .= "<div id=\"cats\" style=\"display: {$display};\">";
 $html .= "<table>";
 $html .= "<tbody align=\"left\"><tr>";

 $i = 0;

 $ncats = count($cats);
 $catsperrow = $ncats;

 $width = 100/$ncats;

 if(count($ncats) > 0);
 foreach( $cats as $cat )
 {
if (file_exists("themes/".$theme."/pics/cat_pics/".$cat['image']))$img = "themes/".$theme."/pics/cat_pics/" . $cat['image'] ;
else
$img = "cat_pics/" . $cat['image'] ;
 $html .= ($i && $i % $catsperrow == 0) ? "</tr><tr>" : "";
 $html .= "<td class=\"nopad\" style=\"padding-bottom: 2px;padding-left: 7px;\"><img src=\"" . $img  . "\" title=\"" . htmlspecialchars($cat['name']) . "\" alt=\"" . htmlspecialchars($cat['name']) . "\" width=\"30px\" border=\"0\">&nbsp;&nbsp;<input id=\"checkAll{$cat[tabletype]}\" type=\"checkbox\" onclick=\"checkAllFields(1,{$cat['tabletype']});\" type=\"checkbox\" " . ($cat['checked'] ? "checked " : "") . "><a href=\"javascript: ShowHideMainSubCats({$cat['tabletype']},{$ncats})\"><img border=\"0\" src=\"themes/eVo_blue/pics/plus.gif\" id=\"pic{$cat['tabletype']}\" alt=\"Show/Hide\">&nbsp;" . htmlspecialchars($cat['name']) . "</a>&nbsp;".(($linkpage != '') ? "<a class=\"catlink\" href=\"{$linkpage}?{$cat['categories']}\">(All)</a>" : "")."</td>\n";
 $i++;
 }



 $nrows = ceil($ncats/$catsperrow);
 $lastrowcols = $ncats % $catsperrow;

 if ($lastrowcols != 0)
 {
 if ($catsperrow - $lastrowcols != 1)
 $html .= "<td rowspan=\"" . ($catsperrow - $lastrowcols) . "\">&nbsp;</td>";
 else
 $html .= "<td>&nbsp;</td>";
 }

 $html .= "</tr><tbody>";
 $html .= "</table>";
 $html .= "</div>";

 if(count($cats) > 0);
 foreach( $cats as $cat )
 {
 $subcats = $cat[subcategory];

 if (count($subcats) > 0)
 {
 $html .= subcategories_table($cat, $wherecatina, $linkpage, $ncats);
 }

 }

 return $html;
}


function subcategories_table($cats, $wherecatina, $linkpage = '', $ncats)
{
global $theme;
 $html = "";
 $html .= "<div id=\"tabletype".$cats['tabletype']."\" style=\"display: none;\">";
 $html .= "<table>";
 $html .= "<tbody align=\"left\"><tr>";
 $width = 100/$ncats;
 $subcats = $cats['subcategory'];
 $catsperrow = $ncats;
 $i = 0;
 if (count($subcats) >0)
 foreach ($subcats as $cat)
 {
if (file_exists("themes/".$theme."/pics/cat_pics/".$cat['image']))$img = "themes/".$theme."/pics/cat_pics/" . $cat['image'] ;
else
 $img = "cat_pics/" . $cat['image'] ;
 $html .= ($i && $i % $catsperrow == 0) ? "</tr><tr>" : "";
 $html .= "<td class=\"subcatlink\" style=\"padding-bottom: 2px;padding-left: 7px; width: ".$width."%;\">"
           ."<img src=\"" . $img  . "\" title=\"" . htmlspecialchars($cat['name']) . "\" alt=\"" . htmlspecialchars($cat['name']) . "\" width=\"30px\" border=\"0\">"
		   ."&nbsp;&nbsp;<input type=\"checkbox\" onclick=\"checkAllFields(2,".$cats['tabletype'].");\" name=\"cats".$cats['tabletype']."[]\" value=\"".$cat['id']."\" type=\"checkbox\" " . (in_array($cat['id'],$wherecatina) ? "checked " : "") . ">"
		   .(($linkpage != '') ? "<a href=\"".$linkpage."?cats".$cats['tabletype']."[]=".$cat['id']."\">" . htmlspecialchars($cat['name']) . "</a>" : htmlspecialchars($cat['name']))."</td>\n";
 $i++;
 }
 $nsubcats = count($subcats);
 $nrows = ceil($nsubcats/$catsperrow);
 $lastrowcols = $nsubcats % $catsperrow;
 if ($lastrowcols != 0)
 {
 if ($catsperrow - $lastrowcols != 1)
 $html .= "<td rowspan=\"" . ($catsperrow - $lastrowcols) . "\">&nbsp;</td>";
 else
 $html .= "<td>&nbsp;</td>";
 }
 $html .= "</tr>";
 $html .= "</tbody>";
 $html .= "</table>";
 $html .= "</div>";
 return $html;
}

Now open upload/torrernt.php and replace
$s = "<select name=\"torrent_category\"><option value=\"0\">("._btchooseone.")</option>\n";
$cats = catlist();
foreach ($cats as $row)
        $s .= "<option value=\"" . $row["id"] . "\">" . htmlspecialchars($row["name"]) . "</option>\n";
$s .= "</select>\n";

with
$s = "<select name=\"torrent_category\"><option value=\"0\">("._btchooseone.")</option>\n";
$cats = genrelist2();
foreach ($cats as $cat)
{
 $s .= "<optgroup label=\"" . htmlspecialchars($cat["name"]) . "\">";
 $subcats = $cat[subcategory];

 if (count($subcats) > 0)
 {
 foreach ($subcats as $subcat)
 {
 $s .= "<option value=\"" . $subcat["id"] . "\">" . htmlspecialchars($subcat["name"]) . "</option>\n";

 }
 }
 $s .= "</optgroup>\n";

}  
$s .= "</select>\n";

Now open upload/link.php and replace
$s = "<select name=\"link_category\"><option value=\"0\">("._btchooseone.")</option>\n";
$cats = catlist();
foreach ($cats as $row)
        $s .= "<option value=\"" . $row["id"] . "\" ".(($link_category == $row["id"]) ? "selected" : "")." >" . htmlspecialchars($row["name"]) . "</option>\n";
$s .= "</select>\n";

with
$s = "<select name=\"link_category\"><option value=\"0\">("._btchooseone.")</option>\n";
$cats = genrelist2();
foreach ($cats as $cat)
{
 $s .= "<optgroup label=\"" . htmlspecialchars($cat["name"]) . "\">";
 $subcats = $cat[subcategory];

 if (count($subcats) > 0)
 {
 foreach ($subcats as $subcat)
 {
 $s .= "<option value=\"" . $subcat["id"] . "\" ".(($link_category == $subcat["id"]) ? "selected" : "")." >" . htmlspecialchars($subcat["name"]) . "</option>\n";

 }
 }
 $s .= "</optgroup>\n";

}  
$s .= "</select>\n";

Now replace the added files
admin/files/categories.php
search.php
torrents.php
and add
this file as brows.js
function ShowHideMainCats(tableCount)
{
	var MainCats = document.getElementById('cats');
	var MainCatsPic = document.getElementById('pic');
	var DefCats = document.getElementById('defcats');

	if (MainCats.style.display == 'none') {
	  MainCats.style.display = 'block';
	  DefCats.style.display = 'block';
	  MainCatsPic.src = 'themes/eVo_blue/pics/minus.gif';
	}
	else {
	  MainCats.style.display = 'none';
	  DefCats.style.display = 'none';
	  MainCatsPic.src = 'themes/eVo_blue/pics/plus.gif';
	}
	
	for(i = 1; i <= tableCount; i++) {
		tableID = 'tabletype' + i;
		tabletype = document.getElementById(tableID);
		picID = 'pic' + i;
		picture = document.getElementById(picID);
		tabletype.style.display = 'none';
		picture.src = 'themes/eVo_blue/pics/plus.gif';
	}
	
}


function ShowHideMainSubCats(tableNum,tableCount){
	
	//Modified http://lists.evolt.org/pipermail/javascript/2006-May/010443.html
	
	if(tableCount > 1)
	for(i = 1; i <= tableCount; i++) {
		tableID = 'tabletype' + i;
		tabletype = document.getElementById(tableID);
		picID = 'pic' + i;
		picture = document.getElementById(picID);
		
		if(i == tableNum){
			if(tabletype.style.display == 'none')
			{
			tabletype.style.display = 'block';
			picture.src = 'themes/eVo_blue/pics/minus.gif';
		    }
			else
			{
			tabletype.style.display = 'none';
			picture.src = 'themes/eVo_blue/pics/plus.gif';
		}
		}
		else
		{
		tabletype.style.display = 'none';
		picture.src = 'themes/eVo_blue/pics/plus.gif';
	}

	}
}

function checkAllFields(ref,tabletype) {
	
	//Modified http://www.dustindiaz.com/check-one-check-all-javascript/
	
	checkAllID = 'checkAll' + tabletype;
    var chkAll = document.getElementById(checkAllID);
	CatsID = 'cats' + tabletype + '[]';
    var checks = document.getElementsByName(CatsID);
 
    var boxLength = checks.length;
    var allChecked = false;
    var totalChecked = 0;
    if (ref == 1) {
        if (chkAll.checked == true) {
            for (i = 0; i < boxLength; i++) {
                checks[i].checked = true;
            }
        } else {
            for (i = 0; i < boxLength; i++) {
                checks[i].checked = false;
            }
        }
    } else {
        for (i = 0; i < boxLength; i++) {
            if (checks[i].checked == true) {
                allChecked = true;
                continue;
            } else {
                allChecked = false;
                break;
            }
        }
        if (allChecked == true) {
            chkAll.checked = true;
        } else {
            chkAll.checked = false;
        }
    }
    for (j = 0; j < boxLength; j++) {
        if (checks[j].checked == true) {
            totalChecked++;
        }
    }

}

//==========================================
// Check All boxes
//==========================================
function CheckAll(fmobj) {
  for (var i=0;i<fmobj.elements.length;i++) {
    var e = fmobj.elements[i];
    if ( (e.name != 'allbox') && (e.type=='checkbox') && (!e.disabled) ) {
      e.checked = fmobj.allbox.checked;
    }
  }
}

//==========================================
// Check all or uncheck all?
//==========================================
function CheckCheckAll(fmobj) {
  var TotalBoxes = 0;
  var TotalOn = 0;
  for (var i=0;i<fmobj.elements.length;i++) {
    var e = fmobj.elements[i];
    if ((e.name != 'allbox') && (e.type=='checkbox')) {
      TotalBoxes++;
      if (e.checked) {
       TotalOn++;
      }
    }
  }
  if (TotalBoxes==TotalOn) {
    fmobj.allbox.checked=true;
  }
  else {
   fmobj.allbox.checked=false;
  }
}


function hide(){

if(document.layers){

document.appgame.visibility="hidden";
document.music.visibility="hidden";
document.other.visibility="hidden";
document.movie.visibility="hidden";

}
if(document.all){

document.all.appgame.style.visibility="hidden";
document.all.music.style.visibility="hidden";
document.all.other.style.visibility="hidden";
document.all.movie.style.visibility="hidden";

}

if(document.getElementById){

document.getElementById('appgame').style.visibility="hidden";
document.getElementById('music').style.visibility="hidden";
document.getElementById('other').style.visibility="hidden";
document.getElementById('movie').style.visibility="hidden";

}
}

function whatbrowser(){
if(document.layers){
thisbrowser="NN4";
}
if(document.all){
thisbrowser="ie";
}
if(!document.all && document.getElementById){
thisbrowser="NN6";
}
}
// -->

function show(z) {

if(document.layers){

document[z].visibility="visible";
}
if(document.all){

document.all[z].style.visibility="visible";
}
if(document.getElementById){

document.getElementById([z]).style.visibility="visible";
}
}

function whatbrowser(){
if(document.layers){
thisbrowser="NN4";
}
if(document.all){
thisbrowser="ie";
}
if(!document.all && document.getElementById){
thisbrowser="NN6";
}
}
// -->


  • Attachment: search.php
    (Size: 13.94KB, Downloaded 56 times)
  • Attachment: torrents.php
    (Size: 9.64KB, Downloaded 56 times)
  • Attachment: categories.php
    (Size: 12.26KB, Downloaded 55 times)


http://a.imageshack.us/img831/5562/mybikes.png

[Updated on: Sun, 18 April 2010 23:22]

Report message to a moderator

Re: subcategories mod [message #3856 is a reply to message #3855] Sun, 11 April 2010 16:29 Go to previous messageGo to next message
joeroberts is currently offline joeroberts  United States
Messages: 1971
Registered: June 2006
Location: U.S.A
Releaser
Da HacKer
I forgot to add subcats menu
In each of your themes find where it shows cat list and replace that with
if (!$onlysearch OR $user->admin) 
{
OpenTable(_bttypes);
echo "<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n<tr>\n<td nowrap>\n";
echo "<p class=\"categories\">";
$i = 0;
foreach (genrelist2() as $c) {
if (file_exists("themes/".$theme."/pics/cat_pics/".$c['image']))$img = "themes/".$theme."/pics/cat_pics/" . $c['image'] ;
else
$img = "cat_pics/" . $c['image'] ;
				if(!$i == 0)echo "<hr>";
                echo "<a class=\"c4\" style=\"cursor: pointer;float:left;\" onclick=\"toggle2('cat".$c['id']."');\"><img title=\"Expand item\" id=\"nn".$extitle."img\" src=\"themes/".$theme."/pics/minus.gif\"  alt=\"+\"></a><img width=\"30px\" src=\"".$img."\" title=\"".$c["name"]."\" border=\"0\" alt=\"".$c["name"]."\" >&nbsp;&nbsp;".$c["name"];
				echo "<hr>";
                echo "<br>";
				$i++;
 $subcats = $c[subcategory];
 if (count($subcats) > 0)
 {
 echo "</div><div id=\"cat".$c['id']."\">";
 foreach ($subcats as $subcat){
if (file_exists("themes/".$theme."/pics/cat_pics/".$subcat['image']))$img = "themes/".$theme."/pics/cat_pics/" . $subcat['image'] ;
else
$img = "cat_pics/" . $subcat['image'] ;
                echo "<a href=\"torrents.php?cat=".$subcat["id"]."\" style=\"padding-bottom: 2px;padding-left: 30px;\">";
                echo "<img width=\"30px\" src=\"".$img."\" title=\"".$subcat["name"]."\" border=\"0\" alt=\"".$subcat["name"]."\" >&nbsp;&nbsp;".$subcat["name"];
                echo "</a>";
                echo "<br>";
}
echo "</div>";
 }
}
echo "</p>";
echo "</td>\n</tr>\n</table>\n";
CloseTable();
}


http://a.imageshack.us/img831/5562/mybikes.png
subcategories mod updated files [message #3913 is a reply to message #3856] Mon, 19 April 2010 01:57 Go to previous messageGo to next message
joeroberts is currently offline joeroberts  United States
Messages: 1971
Registered: June 2006
Location: U.S.A
Releaser
Da HacKer
Browse.js
function ShowHideMainCats(tableCount)
{
	var MainCats = document.getElementById('cats');
	var MainCatsPic = document.getElementById('pic');
	var DefCats = document.getElementById('defcats');

	if (MainCats.style.display == 'none') {
	  MainCats.style.display = 'block';
	  DefCats.style.display = 'block';
	  MainCatsPic.src = 'images/noncross.gif';
	}
	else {
	  MainCats.style.display = 'none';
	  DefCats.style.display = 'none';
	  MainCatsPic.src = 'images/cross.gif';
	}
	
	for(i = 1; i <= tableCount; i++) {
		tableID = 'tabletype' + i;
		tabletype = document.getElementById(tableID);
		picID = 'pic' + i;
		picture = document.getElementById(picID);
		tabletype.style.display = 'none';
		picture.src = 'images/cross.gif';
	}
	
}


function ShowHideMainSubCats(tableNum,tableCount){
	
	//Modified http://lists.evolt.org/pipermail/javascript/2006-May/010443.html
	
	if(tableCount > 1)
	for(i = 1; i <= tableCount; i++) {
		tableID = 'tabletype' + i;
		tabletype = document.getElementById(tableID);
		picID = 'pic' + i;
		picture = document.getElementById(picID);
		
		if(i == tableNum){
			if(tabletype.style.display == 'none')
			{
			tabletype.style.display = 'block';
			picture.src = 'images/noncross.gif';
		    }
			else
			{
			tabletype.style.display = 'none';
			picture.src = 'images/cross.gif';
		}
		}
		else
		{
		tabletype.style.display = 'none';
		picture.src = 'images/cross.gif';
	}

	}
}

function checkAllFields(ref,tabletype) {
	
	//Modified http://www.dustindiaz.com/check-one-check-all-javascript/
	
	checkAllID = 'checkAll' + tabletype;
    var chkAll = document.getElementById(checkAllID);
	CatsID = 'cats' + tabletype + '[]';
    var checks = document.getElementsByName(CatsID);
 
    var boxLength = checks.length;
    var allChecked = false;
    var totalChecked = 0;
    if (ref == 1) {
        if (chkAll.checked == true) {
            for (i = 0; i < boxLength; i++) {
                checks[i].checked = true;
            }
        } else {
            for (i = 0; i < boxLength; i++) {
                checks[i].checked = false;
            }
        }
    } else {
        for (i = 0; i < boxLength; i++) {
            if (checks[i].checked == true) {
                allChecked = true;
                continue;
            } else {
                allChecked = false;
                break;
            }
        }
        if (allChecked == true) {
            chkAll.checked = true;
        } else {
            chkAll.checked = false;
        }
    }
    for (j = 0; j < boxLength; j++) {
        if (checks[j].checked == true) {
            totalChecked++;
        }
    }

}

//==========================================
// Check All boxes
//==========================================
function CheckAll(fmobj) {
  for (var i=0;i<fmobj.elements.length;i++) {
    var e = fmobj.elements[i];
    if ( (e.name != 'allbox') && (e.type=='checkbox') && (!e.disabled) ) {
      e.checked = fmobj.allbox.checked;
    }
  }
}

//==========================================
// Check all or uncheck all?
//==========================================
function CheckCheckAll(fmobj) {
  var TotalBoxes = 0;
  var TotalOn = 0;
  for (var i=0;i<fmobj.elements.length;i++) {
    var e = fmobj.elements[i];
    if ((e.name != 'allbox') && (e.type=='checkbox')) {
      TotalBoxes++;
      if (e.checked) {
       TotalOn++;
      }
    }
  }
  if (TotalBoxes==TotalOn) {
    fmobj.allbox.checked=true;
  }
  else {
   fmobj.allbox.checked=false;
  }
}


function hide(){

if(document.layers){

document.appgame.visibility="hidden";
document.music.visibility="hidden";
document.other.visibility="hidden";
document.movie.visibility="hidden";

}
if(document.all){

document.all.appgame.style.visibility="hidden";
document.all.music.style.visibility="hidden";
document.all.other.style.visibility="hidden";
document.all.movie.style.visibility="hidden";

}

if(document.getElementById){

document.getElementById('appgame').style.visibility="hidden";
document.getElementById('music').style.visibility="hidden";
document.getElementById('other').style.visibility="hidden";
document.getElementById('movie').style.visibility="hidden";

}
}

function whatbrowser(){
if(document.layers){
thisbrowser="NN4";
}
if(document.all){
thisbrowser="ie";
}
if(!document.all && document.getElementById){
thisbrowser="NN6";
}
}
// -->

function show(z) {

if(document.layers){

document[z].visibility="visible";
}
if(document.all){

document.all[z].style.visibility="visible";
}
if(document.getElementById){

document.getElementById([z]).style.visibility="visible";
}
}

function whatbrowser(){
if(document.layers){
thisbrowser="NN4";
}
if(document.all){
thisbrowser="ie";
}
if(!document.all && document.getElementById){
thisbrowser="NN6";
}
}
// -->


catlist
OpenTable(_bttypes);
echo "<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n<tr>\n<td nowrap>\n";
echo "<p class=\"categories\">";
$i = 0;
foreach (genrelist2() as $c) {
if (file_exists("themes/".$theme."/pics/cat_pics/".$c['image']))$img = "themes/".$theme."/pics/cat_pics/" . $c['image'] ;
else
$img = "cat_pics/" . $c['image'] ;
 $subcats = $c['subcategory'];
 $masub=array();
 foreach ($subcats as $subcat2)array_push($masub,$subcat2['id']);
 //print_r($subcats[][0]);
				if(!$i == 0)echo "<hr>";
                echo "<a class=\"c4\" style=\"cursor: pointer;float:left;\" onclick=\"toggle2('cat".$c['id']."');\"><img title=\"Expand item\" id=\"nn".$extitle."img\" src=\"themes/".$theme."/pics/minus.gif\"  alt=\"+\"></a><a href=\"torrents.php?cats".$c["id"]."=".implode("&amp;cats".$c["id"]."=",$masub)."\" ><img width=\"30px\" src=\"".$img."\" title=\"".$c["name"]."\" border=\"0\" alt=\"".$c["name"]."\" >&nbsp;&nbsp;".$c["name"]."</a>";
				echo "<hr>";
                echo "<br>";
				$i++;
						  if (isset($id_pedido) AND $id_pedido == $title) $mostrartable = ''; 
 if (!isset($id_pedido) AND $_COOKIE['cat'.$c['id']] !='') $mostrartable = ' style="display: '.$_COOKIE['cat'.$c['id']].';"';
else $mostrartable = '';
				
 if (count($subcats) > 0)
 {
 echo "</div><div id=\"cat".$c['id']."\"".$mostrartable.">";
 foreach ($subcats as $subcat){
if (file_exists("themes/".$theme."/pics/cat_pics/".$subcat['image']))$img = "themes/".$theme."/pics/cat_pics/" . $subcat['image'] ;
else
$img = "cat_pics/" . $subcat['image'] ;
                echo "<a href=\"torrents.php?cat=".$subcat["id"]."\" style=\"padding-bottom: 2px;padding-left: 30px;\">";
                echo "<img width=\"30px\" src=\"".$img."\" title=\"".$subcat["name"]."\" border=\"0\" alt=\"".$subcat["name"]."\" >&nbsp;&nbsp;".$subcat["name"];
                echo "</a>";
                echo "<br>";
}
echo "</div>";
 }
}
echo "</p>";
echo "</td>\n</tr>\n</table>\n";
CloseTable();
}


[EDIT] functions.php has been updated
  • Attachment: torrents.php
    (Size: 9.77KB, Downloaded 42 times)
  • Attachment: search.php
    (Size: 13.94KB, Downloaded 47 times)
  • Attachment: functions.php
    (Size: 49.72KB, Downloaded 2249 times)


http://a.imageshack.us/img831/5562/mybikes.png

[Updated on: Mon, 19 April 2010 04:00]

Report message to a moderator

Re: subcategories mod updated files [message #5153 is a reply to message #3913] Sun, 05 December 2010 23:33 Go to previous messageGo to next message
Daffy is currently offline Daffy  United Kingdom
Messages: 359
Registered: October 2009
Location: uk
Releaser

have now updated my categories to this script, the part in browser section dosnt show/hide but the block does.

Re: subcategories mod updated files [message #5172 is a reply to message #5153] Tue, 07 December 2010 20:19 Go to previous messageGo to next message
Daffy is currently offline Daffy  United Kingdom
Messages: 359
Registered: October 2009
Location: uk
Releaser

Thanks joe, how would we create seperate blocks for seperate categorys.

Re: subcategories mod updated files [message #5173 is a reply to message #5172] Tue, 07 December 2010 20:24 Go to previous messageGo to next message
joeroberts is currently offline joeroberts  United States
Messages: 1971
Registered: June 2006
Location: U.S.A
Releaser
Da HacKer
How so?

http://a.imageshack.us/img831/5562/mybikes.png
Re: subcategories mod updated files [message #5174 is a reply to message #5173] Tue, 07 December 2010 20:30 Go to previous messageGo to next message
joeroberts is currently offline joeroberts  United States
Messages: 1971
Registered: June 2006
Location: U.S.A
Releaser
Da HacKer
Oh yea and here is a update for include/functions.php
function genrelist2() {
        global $db, $db_prefix;

$row = $db->sql_query("SELECT id, name, image, parent_id, tabletype FROM ".$db_prefix."_categories ORDER BY name");

 while ($mysqlcats = $db->sql_fetchrow($row))
 $allcats[] = $mysqlcats;
$db->sql_freeresult($row);

 $allcats2 = $allcats;
 
 $i = 0;
 
 foreach ($allcats as $cat)
 {

 if ($cat['parent_id'] < 1) 
 {

 $cats[] = $cat;
 $j = 0;
 foreach ($allcats2 as $subcat)
 {

 if ($cat['id'] == $subcat['parent_id']) {

 //Subcategories
 $cats[$i]['subcategory'][] = $subcat;

 //Subcategories add parenttabletype
 $cats[$i]['subcategory'][$j]['parenttabletype'] = $cat['tabletype'];

 //Subcategories add idtabletype
 $cats[$i]['subcategory'][$j]['idtabletype'] = $subcat['id'].$subcat['tabletype'];

 //Subcategories description
 $cats[$i]['subcategory'][$j]['description'] = $cat['name']."->".$subcat['name'];

 //All link array for cats
 $cats[$i]['categories'] .= "cats$cat[tabletype][]=$subcat[id]&amp;";

 $j++;
 }
 }
 
 //All link for cats
 $cats[$i]['categories'] = substr($cats[$i]['categories'],0,-5);
 $i++;

 }

 }

 return $cats;

}

function categories_table($cats, $wherecatina, $linkpage = '', $display = 'block')
{
global $theme;

 $html = "";

 $html .= "<div id=\"cats\" style=\"display: {$display};\">";
 $html .= "<table>";
 $html .= "<tbody align=\"left\"><tr>";

 $i = 0;
 $b = 1;
 $ncats = count($cats);
 $catsperrow = $ncats;

 $width = 100/$ncats;
 if(count($ncats) > 0);
 foreach( $cats as $cat )
 {
if (file_exists("themes/".$theme."/pics/cat_pics/".$cat['image']))$img = "themes/".$theme."/pics/cat_pics/" . $cat['image'] ;
else
$img = "cat_pics/" . $cat['image'] ;
 $html .= ($i && $i % $catsperrow == 0) ? "</tr><tr>" : "";
 $html .= "<td class=\"nopad\" style=\"padding-bottom: 2px;padding-left: 7px;\"><img src=\"" . $img  . "\" title=\"" . htmlspecialchars($cat['name']) . "\" alt=\"" . htmlspecialchars($cat['name']) . "\" width=\"30px\" border=\"0\">&nbsp;&nbsp;<input id=\"checkAll{$cat[tabletype]}\" type=\"checkbox\" onclick=\"checkAllFields(1,{$cat['tabletype']});\" type=\"checkbox\" " . ($cat['checked'] ? "checked " : "") . "><a href=\"javascript: ShowHideMainSubCats(".$b.",{$ncats})\"><img border=\"0\" src=\"themes/".$theme."/pics/plus.gif\" id=\"pic{$b}\" alt=\"Show/Hide\">&nbsp;" . htmlspecialchars($cat['name']) . "</a>&nbsp;".(($linkpage != '') ? "<a class=\"catlink\" href=\"{$linkpage}?{$cat['categories']}\">(All)</a>" : "")."</td>\n";
 $i++;
 $b++;
 }



 $nrows = ceil($ncats/$catsperrow);
 $lastrowcols = $ncats % $catsperrow;

 if ($lastrowcols != 0)
 {
 if ($catsperrow - $lastrowcols != 1)
 $html .= "<td rowspan=\"" . ($catsperrow - $lastrowcols) . "\">&nbsp;</td>";
 else
 $html .= "<td>&nbsp;</td>";
 }

 $html .= "</tr><tbody>";
 $html .= "</table>";
 $html .= "</div>";

 if(count($cats) > 0);
 foreach( $cats as $cat )
 {
 $subcats = $cat[subcategory];

 if (count($subcats) > 0)
 {
 $html .= subcategories_table($cat, $wherecatina, $linkpage, $ncats);
 }

 }

 return $html;
}


function subcategories_table($cats, $wherecatina, $linkpage = '', $ncats)
{
global $theme,$c;
if(!isset($c) OR $c == '')$c = 1;
 $html = "";
 $html .= "<div id=\"tabletype".$c."\" style=\"display: none;\">";
 $html .= "<table>";
 $html .= "<tbody align=\"left\"><tr>";
 $width = 100/$ncats;
 $subcats = $cats['subcategory'];
 $catsperrow = $ncats;
 $i = 0;
 if (count($subcats) >0)
 foreach ($subcats as $cat)
 {
if (file_exists("themes/".$theme."/pics/cat_pics/".$cat['image']))$img = "themes/".$theme."/pics/cat_pics/" . $cat['image'] ;
else
 $img = "cat_pics/" . $cat['image'] ;
 $html .= ($i && $i % $catsperrow == 0) ? "</tr><tr>" : "";
 $html .= "<td class=\"subcatlink\" style=\"padding-bottom: 2px;padding-left: 7px; width: ".$width."%;\">"
           ."<img src=\"" . $img  . "\" class=\"glossy\" title=\"" . htmlspecialchars($cat['name']) . "\" alt=\"" . htmlspecialchars($cat['name']) . "\" width=\"30px\" border=\"0\">"
		   ."&nbsp;&nbsp;<input type=\"checkbox\" onclick=\"checkAllFields(2,".$cats['tabletype'].");\" name=\"cats".$cats['tabletype']."[]\" value=\"".$cat['id']."\" type=\"checkbox\" " . (in_array($cat['id'],$wherecatina) ? "checked " : "") . ">"
		   .(($linkpage != '') ? "<a href=\"".$linkpage."?cats".$cats['tabletype']."[]=".$cat['id']."\">" . htmlspecialchars($cat['name']) . "</a>" : htmlspecialchars($cat['name']))."</td>\n";
 $i++;
 }
 $nsubcats = count($subcats);
 $nrows = ceil($nsubcats/$catsperrow);
 $lastrowcols = $nsubcats % $catsperrow;
 if ($lastrowcols != 0)
 {
 if ($catsperrow - $lastrowcols != 1)
 $html .= "<td rowspan=\"" . ($catsperrow - $lastrowcols) . "\">&nbsp;</td>";
 else
 $html .= "<td>&nbsp;</td>";
 }
 $html .= "</tr>";
 $html .= "</tbody>";
 $html .= "</table>";
 $html .= "</div>";
$c++;
 return $html;
}

and fixed search.php
  • Attachment: search.php
    (Size: 14.39KB, Downloaded 43 times)


http://a.imageshack.us/img831/5562/mybikes.png
Re: subcategories mod [message #5310 is a reply to message #3853] Mon, 31 January 2011 18:54 Go to previous messageGo to next message
Cat_Minister™ is currently offline Cat_Minister™  Netherlands
Messages: 23
Registered: January 2011
Location: where the Cats realm
Leecher
ooooo my i'm lost my friends my head is spinning with this this scares da Cat Smile , witch of all the attachments do i need all of them or ?

haha sorry i'm a noob can i hire somebody to do this part weeee

oke i wil see how i can mannege .. i'm sweating already Sad Smile
Re: subcategories mod [message #5311 is a reply to message #5310] Mon, 31 January 2011 22:20 Go to previous messageGo to next message
Daffy is currently offline Daffy  United Kingdom
Messages: 359
Registered: October 2009
Location: uk
Releaser

message me tomorrow if you have any problems and i will be glad to take some time out to help you Very Happy

Re: subcategories mod [message #5312 is a reply to message #3853] Mon, 31 January 2011 23:59 Go to previous messageGo to next message
Cat_Minister™ is currently offline Cat_Minister™  Netherlands
Messages: 23
Registered: January 2011
Location: where the Cats realm
Leecher
wow thats verry cool of you Daffy ... because i'm realy afraid to mess up my hole site with this you know ...i have already members and i dont want to mess it up

thank you for the amazing help much appreciated Smile
Re: subcategories mod [message #5313 is a reply to message #3853] Tue, 01 February 2011 09:51 Go to previous messageGo to next message
Daffy is currently offline Daffy  United Kingdom
Messages: 359
Registered: October 2009
Location: uk
Releaser

lol no problem, you will only lose categorys assigned to torrents you have installed now. you will not lose torrents or any other infomation. once this modification is installed, you wil need to add cat and sub cats to it, then you can edit torrent listings and assign them to the correct category. i had to edit little under 300 hahaha, worth it in the end as it is a sweet modification.

pm me on here when you are online and if im ok to go, i will start with the install of this modificiation for you.


Re: subcategories mod [message #5633 is a reply to message #3853] Mon, 01 August 2011 12:07 Go to previous messageGo to next message
ZajferX is currently offline ZajferX  Sweden
Messages: 6
Registered: July 2011
Location: Sweden
Leecher
tried this mod now and i get an error when adding a subcat

SQL Error

Error Executing SQL Query INSERT INTO torrent_categories (name, sort_index, image, parent_id, tabletype) VALUES ('Hardcore', '21', 'cat_music_music.gif', '2', '1');
Error ID: 1054
Error Message: Unknown column 'parent_id' in 'field list'
Re: subcategories mod [message #5635 is a reply to message #5633] Mon, 01 August 2011 12:43 Go to previous messageGo to next message
joeroberts is currently offline joeroberts  United States
Messages: 1971
Registered: June 2006
Location: U.S.A
Releaser
Da HacKer
did you replace your torrent_catigory table in the data base?

http://a.imageshack.us/img831/5562/mybikes.png
Re: subcategories mod [message #5900 is a reply to message #5635] Thu, 12 January 2012 20:45 Go to previous messageGo to next message
Pho3niX90 is currently offline Pho3niX90  
Messages: 35
Registered: October 2011
Location: South Africa
Leecher
Hey,

The last catlist breaks my theme, and the one before that one displays correctly, but can't expand or collapse categories, it's always expanded
Re: subcategories mod [message #5909 is a reply to message #5900] Mon, 16 January 2012 06:30 Go to previous message
Pho3niX90 is currently offline Pho3niX90  South Africa
Messages: 35
Registered: October 2011
Location: South Africa
Leecher
Okay, I have noticed when I change the bit "toggle2(" to "toggle(" it works, but then the collapse and expand icon always stay at the collapse pic
Previous Topic:gmail mod
Goto Forum:
  


Current Time: Wed Feb 08 21:59:32 GMT 2012

Total time taken to generate the page: 0.00928 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software