Page 1 of 1
article counter near category name (menu) in visitor page
Posted: Tue 26. Feb 2008, 17:26
by StasMark
hi, I have a question
in this moment I have a web page, based on phpwcms, like a product catalog, but not a eShop, only catalog..
in page articles look like:
question:
how to made, that in visitors page category show article count in category, near category.. like
"Variklis (5)" and it should be near every category ?
p.s.
i'm very sorry for my english
Re: article counter near category name (menu) in visitor page
Posted: Tue 26. Feb 2008, 20:31
by zuker
I understand what StasMark had in mind. He wants to show number of articles placed in particular category.
It should look like this in menu:
Category (5) (Category name (number of 5 articles placed in this category))
Unfortunately I have no answer to his question.
May be others have any suggestion.
Flip-flop is guru of menus
Flip-flop???
Re: article counter near category name (menu) in visitor page
Posted: Wed 27. Feb 2008, 09:39
by Heiko H.
Hi StasMark,
it is not possible at the moment by the existing Navi-RT's. You need to program this feature by yourself.
But I think it is not soooo hard to do.
Good luck, Heiko...
Re: article counter near category name (menu) in visitor page
Posted: Sat 1. Mar 2008, 22:59
by Jensensen
[x]
Re: article counter near category name (menu) in visitor page
Posted: Mon 3. Mar 2008, 00:58
by flip-flop
Hi,
there is a small RT counting the articles of the active category.
Put into /template/inc_script/frontend_render/rt_article_count.php.
Tag: {ARTICLECOUNT}
[EDIT] The old one, please see below[/EDIT]
Code: Select all
<?php
// ================================================================
// Show the count of articles in active category
// 02.03.08 K.H. flip-flop
//
// Thanks to Jensensen for the inspiration
// http://forum.phpwcms.org/viewtopic.php?p=100208#p100208
// Input : {ARTICLECOUNT}
// Output .e.g.: 17
// File: /template/inc_script/frontend_render/rt_article_count.php
// Config: $phpwcms['allow_ext_render'] = 1;
//
// =================================================================
// ----------------------------------------------------------------
// obligate check for phpwcms constants
if (!defined('PHPWCMS_ROOT')) {
die("You Cannot Access This Script Directly, Have a Nice Day.");
}
// ----------------------------------------------------------------
function my_article_count () {
$my_cat_id = $GLOBALS['content']['cat_id'];
$sql = "SELECT * FROM ".DB_PREPEND."phpwcms_article WHERE article_cid=$my_cat_id ";
$sql .= "AND article_public=1 AND article_aktiv=1";
$result = mysql_query($sql);
$num_rows = mysql_num_rows($result);
return $num_rows;
}
// ARTICLECOUNT replacement
if( ! (strpos($content["all"],'{ARTICLECOUNT}')===false)) {
$content["all"] = str_replace('{ARTICLECOUNT}', my_article_count(), $content["all"]);
}
?>
[EDIT] NEW: Reduced this snippet to the minimum.
Code: Select all
<?php
// ================================================================
// Show the count of articles in the active category (V1.1)
// 02.03.08 K.H. flip-flop
// 25.04.08 K.H. Edit V1.1
//
// Thanks to Jensensen for the inspiration
// http://forum.phpwcms.org/viewtopic.php?p=100208#p100208
// Input : {ARTICLECOUNT}
// Output .e.g.: 17
// File: /template/inc_script/frontend_render/rt_article_count.php
// Config: $phpwcms['allow_ext_render'] = 1;
// =================================================================
// ----------------------------------------------------------------
// obligate check for phpwcms constants
if (!defined('PHPWCMS_ROOT')) {
die("You Cannot Access This Script Directly, Have a Nice Day.");
}
// ----------------------------------------------------------------
if( ! (strpos($content["all"],'{ARTICLECOUNT}')===false)) {
$content["all"] = str_replace('{ARTICLECOUNT}', count($GLOBALS['content']["articles"]), $content["all"]);
}
?>
[/EDIT 24.04.08]
Knut
Re: article counter near category name (menu) in visitor page
Posted: Tue 4. Mar 2008, 10:12
by StasMark
Re: article counter near category name (menu) in visitor page
Posted: Tue 18. Mar 2008, 21:36
by Jensensen
didn't checked FE render by flip-flop {should work as well}
but the hack! as posted above
was tested and works fine...
btw.: thank you for smashing our ears....
Re: article counter near category name (menu) in visitor page
Posted: Sat 13. Sep 2008, 06:41
by Jensensen
[x]
Re: article counter near category name (menu) in visitor page
Posted: Sat 13. Sep 2008, 13:52
by flip-flop
Without a hack it is only possible with a new NAV_LIST_UL in frontend_render.
Re: article counter near category name (menu) in visitor page
Posted: Mon 15. Sep 2008, 22:39
by jsw_nz
Here is a variation of the hack that Jensensen documented
I had the problem of not getting article count to match line
so here is a slightly different modification to
function buildCascadingMenu( )
inside front.func.inc.php. It outputs article count inside <a href> </a>- more predictable
Code: Select all
foreach($GLOBALS['content']['struct'] as $key => $value) {
// NEW CODE line 2881 approx.
$temp_sql = "SELECT * FROM ".DB_PREPEND."phpwcms_article WHERE article_cid=$key ";
$temp_sql .= "AND article_public=1 AND article_aktiv=1";
$temp_result = mysql_query($temp_sql);
$temp_num_rows = mysql_num_rows($temp_result);
and
Code: Select all
// ORIGINAL CODE line 2925 approx.
// $li .= '>' . $li_a . '</a>';
$li .= '>' . $li_a . ' ('.$temp_num_rows.')</a>'; // NEW CODE
$li .= $li_ul.'</li>'.LF; // remove $li_ul from this line of code if $ie_patch is used
$x++;
}
mysql_free_result($temp_result); // NEW CODE
}
just a slight modification
Re: article counter near category name (menu) in visitor page
Posted: Mon 15. Sep 2008, 23:11
by Jensensen
[x]
(ready)
ask
Re: article counter near category name (menu) in visitor page
Posted: Mon 15. Sep 2008, 23:14
by flip-flop
$temp_result = mysql_query($temp_sql);
$temp_num_rows = mysql_num_rows($temp_result);
->
$temp_num_rows = _dbCount($temp_sql);
But I think a hack isnĀ“t a good solution.
Yesterday Jens and me have been think about this problem.
A better solution is a enhanced {MY_NAV_LIST_UL:C,......., ID1, ID2, ID3....} or {MY_NAV_LIST_UL:C,........} for all levels. (in frontend_render).
At this time I think the best solution is a replacer in frontend_render. By triggering the Ids produced with NAV_LIST_UL
e.g. <li id="li_article_level_13" class="sub_no"><a href="index.php?ebene06"><span>Ebene06</span></a></li>
Tag: {ARTICLE_COUNT: ID1, ID2, ID3.....} or {ARTICLE_COUNT:0} for all levels.
Found in line li_article_level_XX -> trigger XX -> call the db for article count -> inject the article count before </a> .
This is the most cleanest solution for me, no hack, no second navigation, only a frontend_render script.
Knut
Re: article counter near category name (menu) in visitor page
Posted: Mon 15. Sep 2008, 23:27
by jsw_nz
cheers guys - will follow this thread....
Re: article counter near category name (menu) in visitor page
Posted: Sun 28. Sep 2008, 23:26
by Jensensen
I'm trying another solution that can be found here:
http://forum.phpwcms.org/viewtopic.php?f=8&t=17891