Forum Index
RegisterSearchFAQMemberlistUsergroupsLog in
Problem with multiple categories and other
Goto page 1, 2  Next
 
Reply to topic    Forum Index » Bugs and errors View previous topic
View next topic
Problem with multiple categories and other
Author Message
Moe



Joined: 01 Nov 2006
Posts: 11

Post Problem with multiple categories and other Reply with quote
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:
<?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
Wed Nov 01, 2006 2:43 pm View user's profile Send private message
Guest








Please login to hide the ads.

Pacman15



Joined: 28 Sep 2006
Posts: 10

Post Reply with quote
are categories 12 and 30 parents of 6,7,8,9 ??

_________________
Chocobo Heaven - Powered by Cutenews.Ru! - Final Fantasy Resources
Wed Nov 01, 2006 4:49 pm View user's profile Send private message
Moe



Joined: 01 Nov 2006
Posts: 11

Post Reply with quote
No. they arent.



Edit: Its not only categorie 12 and 30, its form category 12 to 30.
Wed Nov 01, 2006 4:50 pm View user's profile Send private message
FI-DD
Admin


Joined: 22 Sep 2005
Posts: 2736
Location: Germany

Post Reply with quote
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.
Wed Nov 01, 2006 6:25 pm View user's profile Send private message
Moe



Joined: 01 Nov 2006
Posts: 11

Post Reply with quote
Ive downloaded it after the 12th October. So I think i have the latest version.
Wed Nov 01, 2006 7:35 pm View user's profile Send private message
FI-DD
Admin


Joined: 22 Sep 2005
Posts: 2736
Location: Germany

Post Reply with quote
Open show_news.php and find this:

Code:
$cache_uniq = cache_touch_this();




add below:

Code:
echo $category_tmp;




What does it echo out when you go to your page?
Thu Nov 02, 2006 1:14 am View user's profile Send private message
Moe



Joined: 01 Nov 2006
Posts: 11

Post Reply with quote
Hmm, now i see the id of the category above the articles
Sat Nov 04, 2006 2:14 am View user's profile Send private message
FI-DD
Admin


Joined: 22 Sep 2005
Posts: 2736
Location: Germany

Post Reply with quote
Yes, but what IDs exactly?
Mon Nov 06, 2006 6:54 pm View user's profile Send private message
Moe



Joined: 01 Nov 2006
Posts: 11

Post Reply with quote
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)
Tue Nov 07, 2006 11:11 pm View user's profile Send private message
Moe



Joined: 01 Nov 2006
Posts: 11

Post Reply with quote
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?
Wed Nov 08, 2006 12:19 am View user's profile Send private message
FI-DD
Admin


Joined: 22 Sep 2005
Posts: 2736
Location: Germany

Post Reply with quote
Open inc/show.news.php and find this:

Code:
$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:
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.
Wed Nov 08, 2006 1:19 am View user's profile Send private message
Moe



Joined: 01 Nov 2006
Posts: 11

Post Reply with quote
Hmm its getting weirder and weider.

I found a code of you on the following page

http://english.cutenews.ru/forum/viewtopic.php?t=399&highlight=categor%2A



but i did it the other way.

i replaced



Code:
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:
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 Confused



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

By the way, thanks FI-DD for taking time trying to solve my problem
Wed Nov 08, 2006 1:35 am View user's profile Send private message
FI-DD
Admin


Joined: 22 Sep 2005
Posts: 2736
Location: Germany

Post Reply with quote
That's really weird. Confused I have no idea what's happening.
Fri Nov 10, 2006 1:52 am View user's profile Send private message
Faizan



Joined: 11 Dec 2005
Posts: 43

Post Reply with quote
That worked for me too! Thanks!
Fri Apr 06, 2007 12:56 am View user's profile Send private message
scottdallas



Joined: 04 May 2006
Posts: 1843
Location: US

Post Reply with quote
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?

_________________
www.scottdizzle.com uses cnr Smile
last update: 07-22-08: 8:30 pm
Wed Jun 20, 2007 3:25 pm View user's profile Send private message Visit poster's website AIM Address
Display posts from previous:    
Reply to topic    Forum Index » Bugs and errors All times are GMT + 1 Hour
Goto page 1, 2  Next
Page 1 of 2

 
Jump to: 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum



Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Music Lyrics.