 |
 |
 |
 |
 |
| Author |
Message |
Moe
Joined: 01 Nov 2006 Posts: 11
|
|
Problem with multiple categories and other |
|
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:  |  | <?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 |
|
 |
Guest
|
|
|
Please login to hide the ads.
|
|
|
|
 |
Pacman15
Joined: 28 Sep 2006 Posts: 10
|
|
|
|
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 |
|
 |
Moe
Joined: 01 Nov 2006 Posts: 11
|
|
|
|
No. they arent.
Edit: Its not only categorie 12 and 30, its form category 12 to 30.
|
|
| Wed Nov 01, 2006 4:50 pm |
|
 |
FI-DD
Admin

Joined: 22 Sep 2005 Posts: 2736 Location: Germany |
|
|
|
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 |
|
 |
Moe
Joined: 01 Nov 2006 Posts: 11
|
|
|
|
Ive downloaded it after the 12th October. So I think i have the latest version.
|
|
| Wed Nov 01, 2006 7:35 pm |
|
 |
FI-DD
Admin

Joined: 22 Sep 2005 Posts: 2736 Location: Germany |
|
|
|
Open show_news.php and find this:
 |  | $cache_uniq = cache_touch_this(); |
add below:
 |  | echo $category_tmp; |
What does it echo out when you go to your page?
|
|
| Thu Nov 02, 2006 1:14 am |
|
 |
Moe
Joined: 01 Nov 2006 Posts: 11
|
|
|
|
Hmm, now i see the id of the category above the articles
|
|
| Sat Nov 04, 2006 2:14 am |
|
 |
FI-DD
Admin

Joined: 22 Sep 2005 Posts: 2736 Location: Germany |
|
|
|
Yes, but what IDs exactly?
|
|
| Mon Nov 06, 2006 6:54 pm |
|
 |
Moe
Joined: 01 Nov 2006 Posts: 11
|
|
|
|
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 |
|
 |
Moe
Joined: 01 Nov 2006 Posts: 11
|
|
|
|
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 |
|
 |
FI-DD
Admin

Joined: 22 Sep 2005 Posts: 2736 Location: Germany |
|
|
|
Open inc/show.news.php and find this:
 |  | $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:
 |  | 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 |
|
 |
Moe
Joined: 01 Nov 2006 Posts: 11
|
|
|
|
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
 |  | 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
 |  | 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
|
|
| Wed Nov 08, 2006 1:35 am |
|
 |
FI-DD
Admin

Joined: 22 Sep 2005 Posts: 2736 Location: Germany |
|
|
|
That's really weird. I have no idea what's happening.
|
|
| Fri Nov 10, 2006 1:52 am |
|
 |
Faizan

Joined: 11 Dec 2005 Posts: 43
|
|
|
|
That worked for me too! Thanks!
|
|
| Fri Apr 06, 2007 12:56 am |
|
 |
scottdallas

Joined: 04 May 2006 Posts: 1843 Location: US |
|
|
|
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
last update: 07-22-08: 8:30 pm |
|
| Wed Jun 20, 2007 3:25 pm |
|
 |
|
|
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
|
|
 |
 |
 |
|