Problem with multiple categories and other

Report bugs and errors in this forum.

Problem with multiple categories and other

Postby Moe » Wed Nov 01, 2006 2:43 pm

Hi,

first of all excuse me for my bad english. I have a problem with multiple categories. I'll try to explain it as exact as possible.

Well, i created about 30 different categories for my page. On the index page i have a little update section and i want it to show only 4 categories.

So i used the following:
Code: Select all
<?PHP $number=4; $category="6,7,8,9"; $template="update_head"; include $cutepath.'/show_news.php';?>


Well, the problem is that categories 12-30 is also be shown.

How i can i fix it?

Thanks in advance
Moe
 
Posts: 11
Joined: Wed Nov 01, 2006 2:31 pm

Postby Pacman15 » Wed Nov 01, 2006 4:49 pm

are categories 12 and 30 parents of 6,7,8,9 ??
Chocobo Heaven - Powered by Cutenews.Ru! - Final Fantasy Resources
Pacman15
 
Posts: 10
Joined: Thu Sep 28, 2006 5:06 pm

Postby Moe » Wed Nov 01, 2006 4:50 pm

No. they arent.



Edit: Its not only categorie 12 and 30, its form category 12 to 30.
Moe
 
Posts: 11
Joined: Wed Nov 01, 2006 2:31 pm

Postby FI-DD » Wed Nov 01, 2006 6:25 pm

When did you download the script? If it was before October, 12th please download it again because I made changes to the category part of the script. Maybe those changes solve your problem.
User avatar
FI-DD
Admin
 
Posts: 2971
Joined: Thu Sep 22, 2005 11:27 am
Location: Germany

Postby Moe » Wed Nov 01, 2006 7:35 pm

Ive downloaded it after the 12th October. So I think i have the latest version.
Moe
 
Posts: 11
Joined: Wed Nov 01, 2006 2:31 pm

Postby FI-DD » Thu Nov 02, 2006 1:14 am

Open show_news.php and find this:

Code: Select all
$cache_uniq = cache_touch_this();




add below:

Code: Select all
echo $category_tmp;




What does it echo out when you go to your page?
User avatar
FI-DD
Admin
 
Posts: 2971
Joined: Thu Sep 22, 2005 11:27 am
Location: Germany

Postby Moe » Sat Nov 04, 2006 2:14 am

Hmm, now i see the id of the category above the articles
Moe
 
Posts: 11
Joined: Wed Nov 01, 2006 2:31 pm

Postby FI-DD » Mon Nov 06, 2006 6:54 pm

Yes, but what IDs exactly?
User avatar
FI-DD
Admin
 
Posts: 2971
Joined: Thu Sep 22, 2005 11:27 am
Location: Germany

Postby Moe » Tue Nov 07, 2006 11:11 pm

Its IDs 6,3,4,5,7,8,9 (where 6 is parent of 3,4,5)



Its kind of weird. When i only include categories 3,4,5 everything is ok. when i add include 3,4,5,7,8,9 it starts showing the other categories too (i mean 12-31)
Moe
 
Posts: 11
Joined: Wed Nov 01, 2006 2:31 pm

Postby Moe » Wed Nov 08, 2006 12:19 am

Ok, i think i found something. It always shows ids after id 20.

What i mean is the following:

When i include ids 3,4,5 it also shows ids 23,24,24 but no 13,14,15

When i include ids 3,4,5,7,8,9 it also shows ids 23,24,25,27,28,29 but no 13,14,15,17,18,19

I hope you understand what i mean.



Could it be a bug?
Moe
 
Posts: 11
Joined: Wed Nov 01, 2006 2:31 pm

Postby FI-DD » Wed Nov 08, 2006 1:19 am

Open inc/show.news.php and find this:

Code: Select all
$query = $sql->select(array(

       'table'   => 'news',

       'orderby' => $sort,

       'join'      => array('table' => 'story', 'where' => 'id = post_id'),

       'where'   => $where,

       'limit'   => array(($skip ? $skip : 0), $number)

       ));




add above:

Code: Select all
echo_r($allow_categories);

echo_r($where);




Then include IDs 3,4,5 and go to your page, copy the output (the array stuff) and post it here.
User avatar
FI-DD
Admin
 
Posts: 2971
Joined: Thu Sep 22, 2005 11:27 am
Location: Germany

Postby Moe » Wed Nov 08, 2006 1:35 am

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
Moe
 
Posts: 11
Joined: Wed Nov 01, 2006 2:31 pm

Postby FI-DD » Fri Nov 10, 2006 1:52 am

That's really weird. :? I have no idea what's happening.
User avatar
FI-DD
Admin
 
Posts: 2971
Joined: Thu Sep 22, 2005 11:27 am
Location: Germany

Postby Faizan » Fri Apr 06, 2007 12:56 am

That worked for me too! Thanks!
User avatar
Faizan
 
Posts: 55
Joined: Sun Dec 11, 2005 4:26 pm

Postby scottdallas » Wed Jun 20, 2007 3:25 pm

Which fix works? I want to apply this to my master cutenews.ru but I want to apply the right one. Is it FI-DD's or Moe's?
Everyday I'm tumblin http://scodal.tumblr.com
User avatar
scottdallas
 
Posts: 2209
Joined: Thu May 04, 2006 6:46 pm
Location: US

Next

Return to Bugs and errors



Who is online

Users browsing this forum: No registered users and 1 guest