Subcategory System

Started by AMB, October 24, 2011, 01:29:30 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Maverick

#15
kudos....i will try with it..and post what i got...

Mindless

#14
browse.js

Code (html) Select
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 = 'pic/minus.png';
}
else {
  MainCats.style.display = 'none';
  DefCats.style.display = 'none';
  MainCatsPic.src = 'pic/plus.png';
}

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 = 'pic/plus.png';
}

}


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 = 'pic/minus.png';
    }
else
{
tabletype.style.display = 'none';
picture.src = 'pic/plus.png';
}
}
else
{
tabletype.style.display = 'none';
picture.src = 'pic/plus.png';
}

}
}


block - none - play with those and you will get all subcats and maincats showing by default no doubt maybe the 2 display attributes on the function as well, until i have to do it myself i dunno. As you see its all hidden by default so to change that maybe the js file needs to have the opposite value in each call to what it has now - block becomes none - none becomes block im not sure and no got time to test right now because i have the search function in the source in a million bits trying to add Sphinx; Be aware this can turn into a head fuck lol.

Mindless

#13
Well gimmie 5 and i'll see if browse.js can be altered to show all subs as default without breaking code; I have done whats asked on github now by adding a switch to profile to change image or text - Default Tbdev code shows the cats as text with a checkbox so if thats what you want its now default in the code as a switch =]




Maverick

i totally understand what do you mean..btw tht screenshot he posted from ipt..they are using that way...i think he meant to say lts like default...

Mindless

#11
Im no mad at all im just pissed of at how i have to battle to get whats meant lol; AMB posts a picture and i made the per rows globals to be adjusted and he comes back with Lmao its the same.... the picture is u-232 with subcat mods so someones altered it and knows what they done lol - I modded github code and added a switch to profile to allow you to switch to image or text can check that on the test site; All that remains is to alter the javascript attributes to show as default no block and i would imagine browse.js has been altered because it fucks up the display if you alter the display attributes on the function;

Maverick

Mindless Dont get mad...its just a query..everyone has there own way..i guess...and im just asking..just wanted to show cats with there own way....and i dunno what do you mean by posts..if you look at my posts....i always tried to post some new thing or new information here.i are't  here for joking..im running a big tracker and i do love and respect your work thats why i transferred my whole site code to u232....im new in here just trying to gel with the code..nothing else..again dont get mad bud..we all love you..

Regards.

Mindless

#9
You delete the subcat system you kill your tracker unless your capable of reversing all the edits done - The mod is posted in v2 mods; if you wish to remove it be my guest the instructions are all there; its no my problem - im still getting absolutely fuck all detail from both of you - its like drawing blood out a stone on this forum getting any sense but im supposed to be able to decipher what you lot post instantly pmsl.

Maverick

then is there any way to delete subcat system and show cats like that...

Mindless

So was meant to say how to make it display name instead of image and show by default I'm guessing cos a picture says no words - Switch added to allow image or text on github, to get it to show subcat listings by default edit function_subcat.php display attributes although it probably wont work out without altering that code a little its plain to see where, im not altering the main code with that its done like it is for a reason.

Maverick

Mindless I think he whats to show the cats like that (Example -2) instead Of Example 1 on browse.thought so..thats why i tried and posted this one..i guess. ::)

Mindless

#5
And to answer the question its obvious its the same code as current V3 github code, my code was already like that before AMB asked so i only committed my files to github. So let me see AMB - if i define 1 subcat per row on config.php where there defined it will display one subcat per row like the example picture, now i aint no mind reader and the explanation is shite; Be specific with what you want.

AMB

Okay, so it wasn't just me lmao... I thought it was the same as well.

Maverick

#3
i tried mindless but nothing chnaged.. :o..it looks the same code..

<?php
/**
 *   https://github.com/Bigjoos/
 *   Licence Info: GPL
 *   Copyright (C) 2010 U-232 v.3
 *   A bittorrent tracker source based on TBDev.net/tbsource/bytemonsoon.
 *   Project Leaders: Mindless, putyn.
 **/

 
function genrelist2() {
 global 
$mc1$INSTALLER09;
 if(!(
$cats $mc1->get_value('categories'))) {
 
$row sql_query("SELECT id, name, image, parent_id, tabletype FROM categories ORDER BY name");
 while (
$mysqlicats mysqli_fetch_assoc($row))
 
$allcats[] = $mysqlicats;
 
$allcats2 $allcats;
 
$i 0;
 foreach (
$allcats as $cat)
 {
 if (
$cat['parent_id'] == -1
 {
 
$cats[] = $cat;
 
$j 0;
 
$cats[$i]['categories'] = '';
 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++;
 }
 }
 
$mc1->add_value('categories'$cats$INSTALLER09['expires']['genrelist2']);
 }
 return 
$cats;
 }

 function 
categories_table($cats$wherecatina$linkpage ''$display 'block'
 { 
 global 
$lang$CURUSER$INSTALLER09
 
$html ""
 
$html .= "<div id=\"cats\" style=\"display: {$display};\"><table><tbody align=\"left\"><tr>"
 
$i 0
 
$ncats count($cats); 
 if(
count($ncats) > 0); 
 foreach( 
$cats as $cat 
 { 
 
$html .= ($i && $i $INSTALLER09['catsperrow'] == 0) ? "</tr><tr>" ""
 
$html .= "<td class=\"colhead\" style=\"padding-bottom: 2px;padding-left: 7px;white-space: nowrap;\"> 
 <input id=\"checkAll
{$cat['tabletype']}\" type=\"checkbox\" onclick=\"checkAllFields(1,{$cat['tabletype']});\" " . (isset($cat['checked']) && $cat['checked'] ? "checked='checked'" "") . " /> 
 <a href=\"javascript: ShowHideMainSubCats(
{$cat['tabletype']},{$ncats})\"> 
 <img border=\"0\" src=\"pic/plus.png\" 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/$INSTALLER09['catsperrow']); 
 
$lastrowcols $ncats $INSTALLER09['catsperrow']; 
 if (
$lastrowcols != 0
 { 
 if (
$INSTALLER09['catsperrow'] - $lastrowcols != 1
 
$html .= "<td class=\"one\" rowspan=\"" . ($INSTALLER09['catsperrow'] - $lastrowcols) . "\">&nbsp;</td>"
 else 
 
$html .= "<td class=\"one\">&nbsp;</td>"
 } 
 
$html .= "</tr></tbody></table></div>"
 if(
count($cats) > 0); 
 foreach( 
$cats as $cat 
 { 
 
$subcats = isset($cat['subcategory']) && is_array($cat['subcategory']) ? $cat['subcategory'] : array(); 
 if (
count($subcats) > 0
 { 
 
$html .= subcategories_table($cat$wherecatina$linkpage$ncats); 
 } 
 } 
 return 
$html
 } 

function 
subcategories_table($cats$wherecatina = array(), $linkpage ''$ncats) {  
 global 
$lang$CURUSER$INSTALLER09
 
$html ""
 
$html .= "<div id=\"tabletype{$cats['tabletype']}\" style=\"display: none;\">"
 
$subcats $cats['subcategory']; 
 
$html .= "<table>"
 
$html .= "<tbody align=\"left\"><tr>"
 
$i 0
 if (
count($subcats) >0
 foreach (
$subcats as $cat
 { 
 
$html .= ($i && $i $INSTALLER09['subcatperrow'] == 0) ? "</tr><tr>" ""
 
$html .= "<td class=\"one\" style=\"padding-bottom: 2px;padding-left: 7px;white-space: nowrap;\"> 
 <input onclick=\"checkAllFields(2,
{$cats['tabletype']});\" name=\"cats{$cats['tabletype']}[]\" value=\"{$cat['id']}\" type=\"checkbox\" ". (in_array($cat['id'],$wherecatina) ? "checked='checked'" "") . " /> 
 "
.(($linkpage != '') ? "<a href=\"{$linkpage}?cats{$cats['tabletype']}[]={$cat['id']}\"><img src='{$INSTALLER09['pic_base_url']}caticons/{$CURUSER['categorie_icon']}/" htmlspecialchars($cat['image']) . "' alt='" htmlspecialchars($cat['name']) . "' title='" htmlspecialchars($cat['name']) . "' /></a>" htmlspecialchars($cat['name']))."</td>\n"
 
$i++; 
 } 
 
$nsubcats count($subcats); 
 
$nrows ceil($nsubcats/$INSTALLER09['subcatperrow']); 
 
$lastrowcols $nsubcats $INSTALLER09['subcatperrow']; 
 if (
$lastrowcols != 0
 { 
 if (
$INSTALLER09['subcatperrow'] - $lastrowcols != 1
 
$html .= "<td class=\"one\" rowspan=\"".($INSTALLER09['subcatperrow'] - $lastrowcols)."\">&nbsp;</td>"
 else 
 
$html .= "<td class=\"one\">&nbsp;</td>"
 } 
 
$html .= "</tr></tbody></table></div>"
 return 
$html
 }
 
 function 
validsubcat($subcatid,$cats) {
//==Find Category with subcat
$i 0;
if(count($cats) > 0);
foreach ($cats as $cat)
{
$subcats $cat['subcategory'];
if (count($subcats) > 0)
{
foreach ($subcats as $subcat)
{
if ($subcat['id'] == $subcatid)
return True;
}
}
}
return False;
}
?>


Mindless

#2
catsperrow on the function categories_table determines the cats printed on page view, so to then seperate that proper you have to alter function subcategories_table and make catsperrow => subcatperrow then define it as 1 then you will have a straight line of one subcat per row, its all there easy edited.

Add to config :

Code (php) Select
$INSTALLER09['catsperrow'] = 4;
$INSTALLER09['subcatperrow'] = 1;


Set up your two functions like below :

function categories_table($cats, $wherecatina, $linkpage = '', $display = 'block')
{
global $lang, $CURUSER, $INSTALLER09;
$html = "";
$html .= "<div id=\"cats\" style=\"display: {$display};\"><table><tbody align=\"left\"><tr>";
$i = 0;
$ncats = count($cats);
if(count($ncats) > 0);
foreach( $cats as $cat )
{
$html .= ($i && $i % $INSTALLER09['catsperrow'] == 0) ? "</tr><tr>" : "";
$html .= "<td class=\"colhead\" style=\"padding-bottom: 2px;padding-left: 7px;white-space: nowrap;\">
<input id=\"checkAll{$cat['tabletype']}\" type=\"checkbox\" onclick=\"checkAllFields(1,{$cat['tabletype']});\" " . (isset($cat['checked']) && $cat['checked'] ? "checked='checked'" : "") . " />
<a href=\"javascript: ShowHideMainSubCats({$cat['tabletype']},{$ncats})\">
<img border=\"0\" src=\"pic/plus.png\" 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/$INSTALLER09['catsperrow']);
$lastrowcols = $ncats % $INSTALLER09['catsperrow'];
if ($lastrowcols != 0)
{
if ($INSTALLER09['catsperrow'] - $lastrowcols != 1)
$html .= "<td class=\"one\" rowspan=\"" . ($INSTALLER09['catsperrow'] - $lastrowcols) . "\">&nbsp;</td>";
else
$html .= "<td class=\"one\">&nbsp;</td>";
}
$html .= "</tr></tbody></table></div>";
if(count($cats) > 0);
foreach( $cats as $cat )
{
$subcats = isset($cat['subcategory']) && is_array($cat['subcategory']) ? $cat['subcategory'] : array();
if (count($subcats) > 0)
{
$html .= subcategories_table($cat, $wherecatina, $linkpage, $ncats);
}
}
return $html;
}

function subcategories_table($cats, $wherecatina = array(), $linkpage = '', $ncats) { 
global $lang, $CURUSER, $INSTALLER09;
$html = "";
$html .= "<div id=\"tabletype{$cats['tabletype']}\" style=\"display: none;\">";
$subcats = $cats['subcategory'];
$html .= "<table>";
$html .= "<tbody align=\"left\"><tr>";
$i = 0;
if (count($subcats) >0)
foreach ($subcats as $cat)
{
$html .= ($i && $i % $INSTALLER09['subcatperrow'] == 0) ? "</tr><tr>" : "";
$html .= "<td class=\"one\" style=\"padding-bottom: 2px;padding-left: 7px;white-space: nowrap;\">
<input onclick=\"checkAllFields(2,{$cats['tabletype']});\" name=\"cats{$cats['tabletype']}[]\" value=\"{$cat['id']}\" type=\"checkbox\" ". (in_array($cat['id'],$wherecatina) ? "checked='checked'" : "") . " />
".(($linkpage != '') ? "<a href=\"{$linkpage}?cats{$cats['tabletype']}[]={$cat['id']}\"><img src='{$INSTALLER09['pic_base_url']}caticons/{$CURUSER['categorie_icon']}/" . htmlspecialchars($cat['image']) . "' alt='" . htmlspecialchars($cat['name']) . "' title='" . htmlspecialchars($cat['name']) . "' /></a>" : htmlspecialchars($cat['name']))."</td>\n";
$i++;
}
$nsubcats = count($subcats);
$nrows = ceil($nsubcats/$INSTALLER09['subcatperrow']);
$lastrowcols = $nsubcats % $INSTALLER09['subcatperrow'];
if ($lastrowcols != 0)
{
if ($INSTALLER09['subcatperrow'] - $lastrowcols != 1)
$html .= "<td class=\"one\" rowspan=\"".($INSTALLER09['subcatperrow'] - $lastrowcols)."\">&nbsp;</td>";
else
$html .= "<td class=\"one\">&nbsp;</td>";
}
$html .= "</tr></tbody></table></div>";
return $html;
}


Easy as that.

AMB

Hey all,

Was wondering if i could get some help with making the Subcategory System into columns (see example #1) instead of like this (see example #2)...

Example #1:

Example #2:

Here's the link to the Subcategory System thread if you your wondering what i'm talking about :)
https://u-232-forum.duckdns.org/index.php?topic=352.0