|
| Re: subcategories mod [message #3855 is a reply to message #3853] |
Sun, 11 April 2010 16:14   |
|
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\"> <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\"> " . htmlspecialchars($cat['name']) . "</a> ".(($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) . "\"> </td>";
else
$html .= "<td> </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\">"
." <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) . "\"> </td>";
else
$html .= "<td> </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)
[Updated on: Sun, 18 April 2010 23:22] Report message to a moderator
|
|
|
|
|
|
|
|
| Re: subcategories mod updated files [message #5174 is a reply to message #5173] |
Tue, 07 December 2010 20:30   |
|
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]&";
$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\"> <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\"> " . htmlspecialchars($cat['name']) . "</a> ".(($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) . "\"> </td>";
else
$html .= "<td> </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\">"
." <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) . "\"> </td>";
else
$html .= "<td> </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)
|
|
|
| Re: subcategories mod [message #5310 is a reply to message #3853] |
Mon, 31 January 2011 18:54   |
|
ooooo my i'm lost my friends my head is spinning with this this scares da Cat , 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
|
|
|
|
| Re: subcategories mod [message #5312 is a reply to message #3853] |
Mon, 31 January 2011 23:59   |
|
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
|
|
|
|
|
|
|
|