Category problem

Report bugs and errors in this forum.

Category problem

Postby joshers » Fri Mar 17, 2006 2:19 am

I have multiple categories per post. After creating new categories, and adding items with that category, the item wont show up under other categories. Its a strange but and sometimes hard to duplicate.



I would remove the category on the item then it displays.

I'm using txtsql and have maybe 20 categories.



Please help. Any help would be appreciated!
joshers
 
Posts: 68
Joined: Mon Nov 14, 2005 8:03 am

Postby jfade » Sun Apr 02, 2006 8:28 pm

I have the exact same problem, and it's very odd. For example, I had objects assigned to category 6, 70, 71, and 80. It showed up everywhere but category 6. In fact, when you went to open that category the page had everything but the content for that category.



Other times, I've had things that I put in category 103 show up in category 3, so I had to rename another, less used category to make room for the new one, and move things from category 103 to the one I renamed. It is a bit annoying, but I figured it was just cause I had too many categories, but now I see that it happens to other people with less, I know it's not just me.



Some sort of workaround or fix for this would be appreciated. :)
jfade
 
Posts: 3
Joined: Tue Dec 27, 2005 11:49 pm

Postby beef_yo » Mon Sep 25, 2006 10:29 pm

Hi there was this issue ever resolved?



I have a very similar problem, using CustNews.RU 2.5.4 and textSQL.



I have about 20 categories, which includes some subcategories.



Certain combinations of categories fail to show. It is repeatable with those particular combinations, however there doesn't seem to be any rhyme or rule as to why the problem is occurring.



It happens in cat + cat combinations, and cat + subcat combinations.



I have a set up where I have two separate news pages, each displaying separate categories.



Eg page one displays category A and page two displays category B. All posted articles use a combination of these two main categories, plus any additional categories or subcategories.



My problem arises when I post an article with categories A, B & C. With this combination, the article fails to display on page two at all. However it does display correctly on page one. Posting to A & B, or A,B & D displays on both pages without a problem.



Like I said I cannot see any obvious reason for this, and it only appears on particular combinations of categories.



Thoughts?[/b]
beef_yo
 
Posts: 9
Joined: Mon Sep 25, 2006 10:16 pm
Location: New Zealand

Postby FI-DD » Tue Sep 26, 2006 5:50 pm

Can you give me "instructions" so I can duplicate the problem? Without seeing it myself I'm not able to solve it.
User avatar
FI-DD
Admin
 
Posts: 2971
Joined: Thu Sep 22, 2005 11:27 am
Location: Germany

Postby beef_yo » Wed Sep 27, 2006 12:41 am

Thank you very much for your help FI-DD. These instructions take ~5 minutes to run though. Other that the steps mentioned, no other options/actions are taken.



NOTE: I have repeated this ~4 times now with these intstructions, so something is definately up.



Windows Server 2003

IIS 6.0

PHP ver 5.1.6



1. Extract cnr_2.5.4 (eng).zip to a directory on the server



2. Create a news display page (news.php) in script directory with the following:

Code: Select all

<?

include 'head.php';

?>

<?php

$category = '2,3';

$number = 20;

include $cutepath.'/show_news.php';

?>





3. Run index.php

    all dirs & files rwx

    Language = english

    Database = textSQL

    User,PW = test,test



4. Log in to admin as test,test



5. Delete install directory as advised



6. Goto Options > Manage Categories



7. Create the inital set of categories:

New category

-a,b,c,d,e



8. Create category a's subcategories:

New Category (all with a as parent)

a1,a2,a3



9. Create category b's subcategories:

New Category (all with b as parent)

b1,b2,b3



10. Create category c's subcategories:

New Category (all with c as parent)

c1,c2,c3



You will end up with the following categories and id's:

Code: Select all

ID    Name

1   a    

6   a1    

7   a2    

8   a3    

2   b    

9   b1    

10     b2    

11     b3    

3   c    

12     c1    

13     c2    

14     c3    

4   d    

5   e    



11. Add a news article:

-Title = test1

-Short Story = blah

-Category a,b,c



12. Add a news article:

-Title = test2

-Short Story = blah

-Category a,b,c,c2





When you open news.php only the test1 article will display, even though you have chosen to display categories b (id 2) and c (id 3), and both articles have those categories



Update:Also interestingly enough, if you post a news article to category a (id 1) with this setup it still actually shows up, even though news.php is only configured to display category's b (id 2) & c (id 3)
beef_yo
 
Posts: 9
Joined: Mon Sep 25, 2006 10:16 pm
Location: New Zealand

Postby FI-DD » Wed Sep 27, 2006 2:16 pm

You are right. The function category_get_children() is not working correctly.



Open inc/functions.inc.php and replace the function with this (taken from Strawberry 1.1.1):

Code: Select all
function category_get_children($id, $withid = true, $limit = 0){

global $cat_parent;

static $end = 1, $result = array();



   $categories_dummy = $cat_parent;



   if ($id === ''){

      return false;

   }



   if ($withid){

      $result[] = $id;

   }



   foreach ($categories_dummy as $cat_id => $row){

      if ($row == $id){

         $result[] = $cat_id;



         if ($limit - $end){

            $result[] = category_get_children($cat_id, $limit);

         }

      }

   }



   $end++;



   $return = $result;

   $result = array();



return join(',', $return);

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

Postby beef_yo » Thu Sep 28, 2006 12:13 am

Hi FI-DD,



That worked a charm! In the above example I can now select every listed category and the news article will display.



However the second problem still lingers: If you post a news article to category a (id 1) with this setup it still actually shows up, even though news.php is only configured to display category's b (id 2) & c (id 3).



Select category d (id 4) also produces this behaviour, however selecting category e (id 5) does not.



Any assistance would be greatly appreciated! :D
beef_yo
 
Posts: 9
Joined: Mon Sep 25, 2006 10:16 pm
Location: New Zealand

Postby FI-DD » Thu Sep 28, 2006 1:29 pm

Open inc/show.news.php and replace 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.'%';

            }

         }

      }

   }




with this:

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]);

   }
Last edited by FI-DD on Fri Sep 29, 2006 11:29 am, edited 1 time in total.
User avatar
FI-DD
Admin
 
Posts: 2971
Joined: Thu Sep 22, 2005 11:27 am
Location: Germany

Postby beef_yo » Thu Sep 28, 2006 11:56 pm

Hi FI-DD,



That last section of code produces very strange behaviour.



What doesn't show:

b + c

b

c

a + b + c + d + e

a + b + c + d + e + a1



What does show:

b + b1

b + c1

c + b1

c + c1

a + b + c + d + e + a1 + b1



It seems that unless you specifically include a sub-category of the categories defined in the $category variable, news will not display.



It also pays to note that if you do not define the $category variable, then no news displays at all.
beef_yo
 
Posts: 9
Joined: Mon Sep 25, 2006 10:16 pm
Location: New Zealand

Postby FI-DD » Fri Sep 29, 2006 12:03 am

Oh well, I'm not sure if I will ever get this working. :(



I'll keep on trying.
User avatar
FI-DD
Admin
 
Posts: 2971
Joined: Thu Sep 22, 2005 11:27 am
Location: Germany

Postby beef_yo » Fri Sep 29, 2006 2:41 am

Haha I'm sorry I picked out a hard one. I really admire the amount of effort you've put in so far though - and the promptness!



I guess the problem is it's quite a fundamental component of the categories feature too :(



Once again - thanks for your help! :D
beef_yo
 
Posts: 9
Joined: Mon Sep 25, 2006 10:16 pm
Location: New Zealand

Postby FI-DD » Fri Sep 29, 2006 11:37 am

beef_yo wrote:It also pays to note that if you do not define the $category variable, then no news displays at all.


That's true, I fixed it above.



beef_yo wrote:What doesn't show:

b + c

b

c

a + b + c + d + e

a + b + c + d + e + a1


All of the examples are showing for me. :shock:
Last edited by FI-DD on Tue Oct 10, 2006 11:23 pm, edited 1 time in total.
User avatar
FI-DD
Admin
 
Posts: 2971
Joined: Thu Sep 22, 2005 11:27 am
Location: Germany

Postby beef_yo » Mon Oct 02, 2006 2:10 am

Worked a charm!



The world is right once again! :D



You've done great work FI-DD.



Cheers
beef_yo
 
Posts: 9
Joined: Mon Sep 25, 2006 10:16 pm
Location: New Zealand


Return to Bugs and errors



Who is online

Users browsing this forum: No registered users and 0 guests

cron