Problem with multiple categories and other

Report bugs and errors in this forum.

Postby FI-DD » Fri Jun 22, 2007 1:30 pm

For some people it seems to work to activate the disabled part and to disable the activated part in inc/show.news.php - just like Moe said.
User avatar
FI-DD
Admin
 
Posts: 2971
Joined: Thu Sep 22, 2005 11:27 am
Location: Germany

Postby Mania » Thu Dec 27, 2007 9:44 pm

:D
i solved this problem so:
the orginal code in inc/show.newws.php begin with line 44 to 86:
Code: Select all
   /*if (reset($allow_categories)){

      $where[] = 'and';

      $where[] = 'category =~ %'.(count($allow_categories) > 1 ? '['.join('|', $allow_categories).']' : join('', $allow_categories)).'%';



      foreach ($allow_categories as $k => $v){

         for ($i = 0; $i < 10; $i++){

            if (!in_array($v.$i, $allow_categories)){

               $where[] = 'and';

               $where[] = 'category !~ %'.$v.$i.'%';

            }



            if (!in_array($i.$v, $allow_categories)){

               $where[] = 'and';

               $where[] = 'category !~ %'.$i.$v.'%';

            }

         }

      }

   }*/

   

   

   if ($allow_categories[0] != ''){

      foreach ($allow_categories as $k => $v){

         for ($i = 0; $i < 10; $i++){

            if (!in_array($v.$i, $allow_categories)){

               $where[] = 'and';

               $where[] = 'category !~ %'.$v.$i.'%';

            }



            if (!in_array($i.$v, $allow_categories)){

               $where[] = 'and';

               $where[] = 'category !~ %'.$i.$v.'%';

            }

         }

      }

      

      $where[] = 'and';

      foreach($allow_categories as $single_cat){

         $where[] = 'category =~ %'.$single_cat.'%';

         $where[] = 'or';

      }

      

      unset($where[count($where)-1]);

   }

i active the parte 1 and deactive part2 so:
Code: Select all
if (reset($allow_categories)){

      $where[] = 'and';

      $where[] = 'category =~ %'.(count($allow_categories) > 1 ? '['.join('|', $allow_categories).']' : join('', $allow_categories)).'%';



      foreach ($allow_categories as $k => $v){

         for ($i = 0; $i < 10; $i++){

            if (!in_array($v.$i, $allow_categories)){

               $where[] = 'and';

               $where[] = 'category !~ %'.$v.$i.'%';

            }



            if (!in_array($i.$v, $allow_categories)){

               $where[] = 'and';

               $where[] = 'category !~ %'.$i.$v.'%';

            }

         }

      }

   }

   

   

/*   if ($allow_categories[0] != ''){

      foreach ($allow_categories as $k => $v){

         for ($i = 0; $i < 10; $i++){

            if (!in_array($v.$i, $allow_categories)){

               $where[] = 'and';

               $where[] = 'category !~ %'.$v.$i.'%';

            }



            if (!in_array($i.$v, $allow_categories)){

               $where[] = 'and';

               $where[] = 'category !~ %'.$i.$v.'%';

            }

         }

      }

      

      $where[] = 'and';

      foreach($allow_categories as $single_cat){

         $where[] = 'category =~ %'.$single_cat.'%';

         $where[] = 'or';

      }

      

      unset($where[count($where)-1]);

   }
*/

is work :D
but which surprises me!?!
why don't you make Cutenews 2.5.4 also in such a way in orginal file from!??
that cost me 6 to grant :lol:

:D
User avatar
Mania
 
Posts: 178
Joined: Sat Feb 03, 2007 1:12 pm

Postby SolidSnake2003 » Sun Feb 24, 2008 12:03 am

I tried the about solution, and I got this error:

Parse error: syntax error, unexpected $end in /my/site/info/admin/inc/show.news.php on line 386

Attention FIDD, here is an answer to your previous post by someone who didnt answer as I tried your solution, here is the array output that you asked for:

Array
(
[0] => 1
[1] => 4
[2] => 5
[3] => 6
[4] => 7
[5] => 8
[6] => 9
[7] => 10
[8] => 11
[9] => 12
[10] => 13
[11] => 14
[12] => 15
)
Array
(
[0] => date < 1203807392
[1] => and
[2] => category !~ %21%
[3] => and
[4] => category !~ %31%
[5] => and
[6] => category !~ %41%
[7] => and
[8] => category !~ %51%
[9] => and
[10] => category !~ %16%
[11] => and
[12] => category !~ %61%
[13] => and
[14] => category !~ %17%
[15] => and
[16] => category !~ %71%
[17] => and
[18] => category !~ %18%
[19] => and
[20] => category !~ %81%
[21] => and
[22] => category !~ %19%
[23] => and
[24] => category !~ %91%
[25] => and
[26] => category !~ %40%
[27] => and
[28] => category !~ %41%
[29] => and
[30] => category !~ %42%
[31] => and
[32] => category !~ %24%
[33] => and
[34] => category !~ %43%
[35] => and
[36] => category !~ %34%
[37] => and
[38] => category !~ %44%
[39] => and
[40] => category !~ %44%
[41] => and
[42] => category !~ %45%
[43] => and
[44] => category !~ %54%
[45] => and
[46] => category !~ %46%
[47] => and
[48] => category !~ %64%
[49] => and
[50] => category !~ %47%
[51] => and
[52] => category !~ %74%
[53] => and
[54] => category !~ %48%
[55] => and
[56] => category !~ %84%
[57] => and
[58] => category !~ %49%
[59] => and
[60] => category !~ %94%
[61] => and
[62] => category !~ %50%
[63] => and
[64] => category !~ %51%
[65] => and
[66] => category !~ %52%
[67] => and
[68] => category !~ %25%
[69] => and
[70] => category !~ %53%
[71] => and
[72] => category !~ %35%
[73] => and
[74] => category !~ %54%
[75] => and
[76] => category !~ %45%
[77] => and
[78] => category !~ %55%
[79] => and
[80] => category !~ %55%
[81] => and
[82] => category !~ %56%
[83] => and
[84] => category !~ %65%
[85] => and
[86] => category !~ %57%
[87] => and
[88] => category !~ %75%
[89] => and
[90] => category !~ %58%
[91] => and
[92] => category !~ %85%
[93] => and
[94] => category !~ %59%
[95] => and
[96] => category !~ %95%
[97] => and
[98] => category !~ %60%
[99] => and
[100] => category !~ %61%
[101] => and
[102] => category !~ %16%
[103] => and
[104] => category !~ %62%
[105] => and
[106] => category !~ %26%
[107] => and
[108] => category !~ %63%
[109] => and
[110] => category !~ %36%
[111] => and
[112] => category !~ %64%
[113] => and
[114] => category !~ %46%
[115] => and
[116] => category !~ %65%
[117] => and
[118] => category !~ %56%
[119] => and
[120] => category !~ %66%
[121] => and
[122] => category !~ %66%
[123] => and
[124] => category !~ %67%
[125] => and
[126] => category !~ %76%
[127] => and
[128] => category !~ %68%
[129] => and
[130] => category !~ %86%
[131] => and
[132] => category !~ %69%
[133] => and
[134] => category !~ %96%
[135] => and
[136] => category !~ %70%
[137] => and
[138] => category !~ %71%
[139] => and
[140] => category !~ %17%
[141] => and
[142] => category !~ %72%
[143] => and
[144] => category !~ %27%
[145] => and
[146] => category !~ %73%
[147] => and
[148] => category !~ %37%
[149] => and
[150] => category !~ %74%
[151] => and
[152] => category !~ %47%
[153] => and
[154] => category !~ %75%
[155] => and
[156] => category !~ %57%
[157] => and
[158] => category !~ %76%
[159] => and
[160] => category !~ %67%
[161] => and
[162] => category !~ %77%
[163] => and
[164] => category !~ %77%
[165] => and
[166] => category !~ %78%
[167] => and
[168] => category !~ %87%
[169] => and
[170] => category !~ %79%
[171] => and
[172] => category !~ %97%
[173] => and
[174] => category !~ %80%
[175] => and
[176] => category !~ %81%
[177] => and
[178] => category !~ %18%
[179] => and
[180] => category !~ %82%
[181] => and
[182] => category !~ %28%
[183] => and
[184] => category !~ %83%
[185] => and
[186] => category !~ %38%
[187] => and
[188] => category !~ %84%
[189] => and
[190] => category !~ %48%
[191] => and
[192] => category !~ %85%
[193] => and
[194] => category !~ %58%
[195] => and
[196] => category !~ %86%
[197] => and
[198] => category !~ %68%
[199] => and
[200] => category !~ %87%
[201] => and
[202] => category !~ %78%
[203] => and
[204] => category !~ %88%
[205] => and
[206] => category !~ %88%
[207] => and
[208] => category !~ %89%
[209] => and
[210] => category !~ %98%
[211] => and
[212] => category !~ %90%
[213] => and
[214] => category !~ %91%
[215] => and
[216] => category !~ %19%
[217] => and
[218] => category !~ %92%
[219] => and
[220] => category !~ %29%
[221] => and
[222] => category !~ %93%
[223] => and
[224] => category !~ %39%
[225] => and
[226] => category !~ %94%
[227] => and
[228] => category !~ %49%
[229] => and
[230] => category !~ %95%
[231] => and
[232] => category !~ %59%
[233] => and
[234] => category !~ %96%
[235] => and
[236] => category !~ %69%
[237] => and
[238] => category !~ %97%
[239] => and
[240] => category !~ %79%
[241] => and
[242] => category !~ %98%
[243] => and
[244] => category !~ %89%
[245] => and
[246] => category !~ %99%
[247] => and
[248] => category !~ %99%
[249] => and
[250] => category !~ %100%
[251] => and
[252] => category !~ %101%
[253] => and
[254] => category !~ %110%
[255] => and
[256] => category !~ %102%
[257] => and
[258] => category !~ %210%
[259] => and
[260] => category !~ %103%
[261] => and
[262] => category !~ %310%
[263] => and
[264] => category !~ %104%
[265] => and
[266] => category !~ %410%
[267] => and
[268] => category !~ %105%
[269] => and
[270] => category !~ %510%
[271] => and
[272] => category !~ %106%
[273] => and
[274] => category !~ %610%
[275] => and
[276] => category !~ %107%
[277] => and
[278] => category !~ %710%
[279] => and
[280] => category !~ %108%
[281] => and
[282] => category !~ %810%
[283] => and
[284] => category !~ %109%
[285] => and
[286] => category !~ %910%
[287] => and
[288] => category !~ %110%
[289] => and
[290] => category !~ %111%
[291] => and
[292] => category !~ %111%
[293] => and
[294] => category !~ %112%
[295] => and
[296] => category !~ %211%
[297] => and
[298] => category !~ %113%
[299] => and
[300] => category !~ %311%
[301] => and
[302] => category !~ %114%
[303] => and
[304] => category !~ %411%
[305] => and
[306] => category !~ %115%
[307] => and
[308] => category !~ %511%
[309] => and
[310] => category !~ %116%
[311] => and
[312] => category !~ %611%
[313] => and
[314] => category !~ %117%
[315] => and
[316] => category !~ %711%
[317] => and
[318] => category !~ %118%
[319] => and
[320] => category !~ %811%
[321] => and
[322] => category !~ %119%
[323] => and
[324] => category !~ %911%
[325] => and
[326] => category !~ %120%
[327] => and
[328] => category !~ %121%
[329] => and
[330] => category !~ %112%
[331] => and
[332] => category !~ %122%
[333] => and
[334] => category !~ %212%
[335] => and
[336] => category !~ %123%
[337] => and
[338] => category !~ %312%
[339] => and
[340] => category !~ %124%
[341] => and
[342] => category !~ %412%
[343] => and
[344] => category !~ %125%
[345] => and
[346] => category !~ %512%
[347] => and
[348] => category !~ %126%
[349] => and
[350] => category !~ %612%
[351] => and
[352] => category !~ %127%
[353] => and
[354] => category !~ %712%
[355] => and
[356] => category !~ %128%
[357] => and
[358] => category !~ %812%
[359] => and
[360] => category !~ %129%
[361] => and
[362] => category !~ %912%
[363] => and
[364] => category !~ %130%
[365] => and
[366] => category !~ %131%
[367] => and
[368] => category !~ %113%
[369] => and
[370] => category !~ %132%
[371] => and
[372] => category !~ %213%
[373] => and
[374] => category !~ %133%
[375] => and
[376] => category !~ %313%
[377] => and
[378] => category !~ %134%
[379] => and
[380] => category !~ %413%
[381] => and
[382] => category !~ %135%
[383] => and
[384] => category !~ %513%
[385] => and
[386] => category !~ %136%
[387] => and
[388] => category !~ %613%
[389] => and
[390] => category !~ %137%
[391] => and
[392] => category !~ %713%
[393] => and
[394] => category !~ %138%
[395] => and
[396] => category !~ %813%
[397] => and
[398] => category !~ %139%
[399] => and
[400] => category !~ %913%
[401] => and
[402] => category !~ %140%
[403] => and
[404] => category !~ %141%
[405] => and
[406] => category !~ %114%
[407] => and
[408] => category !~ %142%
[409] => and
[410] => category !~ %214%
[411] => and
[412] => category !~ %143%
[413] => and
[414] => category !~ %314%
[415] => and
[416] => category !~ %144%
[417] => and
[418] => category !~ %414%
[419] => and
[420] => category !~ %145%
[421] => and
[422] => category !~ %514%
[423] => and
[424] => category !~ %146%
[425] => and
[426] => category !~ %614%
[427] => and
[428] => category !~ %147%
[429] => and
[430] => category !~ %714%
[431] => and
[432] => category !~ %148%
[433] => and
[434] => category !~ %814%
[435] => and
[436] => category !~ %149%
[437] => and
[438] => category !~ %914%
[439] => and
[440] => category !~ %150%
[441] => and
[442] => category !~ %151%
[443] => and
[444] => category !~ %115%
[445] => and
[446] => category !~ %152%
[447] => and
[448] => category !~ %215%
[449] => and
[450] => category !~ %153%
[451] => and
[452] => category !~ %315%
[453] => and
[454] => category !~ %154%
[455] => and
[456] => category !~ %415%
[457] => and
[458] => category !~ %155%
[459] => and
[460] => category !~ %515%
[461] => and
[462] => category !~ %156%
[463] => and
[464] => category !~ %615%
[465] => and
[466] => category !~ %157%
[467] => and
[468] => category !~ %715%
[469] => and
[470] => category !~ %158%
[471] => and
[472] => category !~ %815%
[473] => and
[474] => category !~ %159%
[475] => and
[476] => category !~ %915%
[477] => and
[478] => category =~ %1%
[479] => or
[480] => category =~ %4%
[481] => or
[482] => category =~ %5%
[483] => or
[484] => category =~ %6%
[485] => or
[486] => category =~ %7%
[487] => or
[488] => category =~ %8%
[489] => or
[490] => category =~ %9%
[491] => or
[492] => category =~ %10%
[493] => or
[494] => category =~ %11%
[495] => or
[496] => category =~ %12%
[497] => or
[498] => category =~ %13%
[499] => or
[500] => category =~ %14%
[501] => or
[502] => category =~ %15%
)a
User avatar
SolidSnake2003
 
Posts: 68
Joined: Tue Jul 31, 2007 3:26 am

Postby FI-DD » Wed Feb 27, 2008 8:48 pm

And what category is shown although it's not supposed to show?
User avatar
FI-DD
Admin
 
Posts: 2971
Joined: Thu Sep 22, 2005 11:27 am
Location: Germany

Postby SolidSnake2003 » Sat Mar 01, 2008 10:59 am

I told it to show Category 2, but it was showing 12, and 12 as well as the sub-categories of 2 which was 2-11, and 12 and 22 were not sub categories of 2
User avatar
SolidSnake2003
 
Posts: 68
Joined: Tue Jul 31, 2007 3:26 am

Postby FI-DD » Thu May 29, 2008 7:07 pm

User avatar
FI-DD
Admin
 
Posts: 2971
Joined: Thu Sep 22, 2005 11:27 am
Location: Germany

Postby DistantJ » Fri Jul 31, 2009 5:03 pm

Neither of these fixes work for me...

Switching back to the old if (reset($allow_categories)){ stops it from displaying more than on category.

It could be to do with the fact that my categories go 1, 2, 3, 4, 9, 10, etc... because I deleted some when using the original cutenews and it doesn't remove the number. I've decided to try removing all categories and starting again with them...
DistantJ
 
Posts: 33
Joined: Tue Jul 29, 2008 10:27 am

Postby samiro » Mon Mar 22, 2010 12:14 pm

Moe wrote:Hmm its getting weirder and weider.

I found a code of you on the following page

http://english.cutenews.ru/forum/viewto ... categor%2A



but i did it the other way.

i replaced



Code: Select all
if ($allow_categories[0] != ''){

      foreach ($allow_categories as $k => $v){

         for ($i = 0; $i < 10; $i++){

            if (!in_array($v.$i, $allow_categories)){

               $where[] = 'and';

               $where[] = 'category !~ %'.$v.$i.'%';

            }



            if (!in_array($i.$v, $allow_categories)){

               $where[] = 'and';

               $where[] = 'category !~ %'.$i.$v.'%';

            }

         }

      }

     

      $where[] = 'and';

      foreach($allow_categories as $single_cat){

         $where[] = 'category =~ %'.$single_cat.'%';

         $where[] = 'or';

      }

     

      unset($where[count($where)-1]);

   }




with this

Code: Select all
if (reset($allow_categories)){

      $where[] = 'and';

      $where[] = 'category =~ %'.(count($allow_categories) > 1 ? '['.join('|', $allow_categories).']' : join('', $allow_categories)).'%';



      foreach ($allow_categories as $k => $v){

         for ($i = 0; $i < 10; $i++){

            if (!in_array($v.$i, $allow_categories)){

               $where[] = 'and';

               $where[] = 'category !~ %'.$v.$i.'%';

            }



            if (!in_array($i.$v, $allow_categories)){

               $where[] = 'and';

               $where[] = 'category !~ %'.$i.$v.'%';

            }

         }

      }

   }




and... surprise... everything is working correctly :?



Unfortunately im a php-newbie. so how could this be???

By the way, thanks FI-DD for taking time trying to solve my problem


this also fix my problem !!!!
http://forums.cutenewsru.com/viewtopic. ... categories
User avatar
samiro
 
Posts: 103
Joined: Sun Apr 20, 2008 1:52 pm
Location: IL

Previous

Return to Bugs and errors



Who is online

Users browsing this forum: No registered users and 0 guests