article counter near category name (menu) in visitor page

Get help with installation and running phpwcms here. Please do not post bug reports or feature requests here.
Post Reply
StasMark
Posts: 11
Joined: Tue 22. May 2007, 16:29

article counter near category name (menu) in visitor page

Post 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..
Image
Image
in page articles look like:
Image

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 :(
zuker
Posts: 80
Joined: Fri 18. May 2007, 17:13
Location: Lithuania

Re: article counter near category name (menu) in visitor page

Post 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))

Image

Unfortunately I have no answer to his question.

May be others have any suggestion.

Flip-flop is guru of menus

Flip-flop???
٩(͡๏̯͡๏)۶
User avatar
Heiko H.
Posts: 868
Joined: Thu 27. Oct 2005, 11:41
Location: Dresden
Contact:

Re: article counter near category name (menu) in visitor page

Post 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...
Not longer here - sorry...

Haubner-IT GbR Dresden
User avatar
Jensensen
Posts: 3000
Joined: Tue 17. Oct 2006, 21:11
Location: auf der mlauer

Re: article counter near category name (menu) in visitor page

Post by Jensensen »

[x]
Last edited by Jensensen on Sat 20. Sep 2008, 03:41, edited 1 time in total.
{so_much} | Knick-Knack. | GitHub
Umlaute im URL sind meistens immer Kacke.
User avatar
flip-flop
Moderator
Posts: 8178
Joined: Sat 21. May 2005, 21:25
Location: HAMM (Germany)
Contact:

Re: article counter near category name (menu) in visitor page

Post 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
Last edited by flip-flop on Fri 25. Apr 2008, 10:01, edited 1 time in total.
>> HowTo | DOCU | FAQ | TEMPLATES/DOCS << ( SITE )
StasMark
Posts: 11
Joined: Tue 22. May 2007, 16:29

Re: article counter near category name (menu) in visitor page

Post by StasMark »

flip-flop, not worked..
i make a video to show it:
turn off sound
http://www.youtube.com/watch?v=bkIxRKGGYeM
and video file can find on normal resolution can find:
http://rapidshare.com/files/97672632/arc_count.avi.html
or
http://customvirus.lt/arcount.rar
User avatar
Jensensen
Posts: 3000
Joined: Tue 17. Oct 2006, 21:11
Location: auf der mlauer

Re: article counter near category name (menu) in visitor page

Post 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....
{so_much} | Knick-Knack. | GitHub
Umlaute im URL sind meistens immer Kacke.
User avatar
Jensensen
Posts: 3000
Joined: Tue 17. Oct 2006, 21:11
Location: auf der mlauer

Re: article counter near category name (menu) in visitor page

Post by Jensensen »

[x]
Last edited by Jensensen on Sat 20. Sep 2008, 00:03, edited 1 time in total.
{so_much} | Knick-Knack. | GitHub
Umlaute im URL sind meistens immer Kacke.
User avatar
flip-flop
Moderator
Posts: 8178
Joined: Sat 21. May 2005, 21:25
Location: HAMM (Germany)
Contact:

Re: article counter near category name (menu) in visitor page

Post by flip-flop »

Without a hack it is only possible with a new NAV_LIST_UL in frontend_render.
>> HowTo | DOCU | FAQ | TEMPLATES/DOCS << ( SITE )
User avatar
jsw_nz
Posts: 907
Joined: Fri 2. Apr 2004, 02:42
Location: New Zealand

Re: article counter near category name (menu) in visitor page

Post 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
:D
User avatar
Jensensen
Posts: 3000
Joined: Tue 17. Oct 2006, 21:11
Location: auf der mlauer

Re: article counter near category name (menu) in visitor page

Post by Jensensen »

[x]
(ready)
ask
Last edited by Jensensen on Fri 19. Sep 2008, 23:52, edited 1 time in total.
{so_much} | Knick-Knack. | GitHub
Umlaute im URL sind meistens immer Kacke.
User avatar
flip-flop
Moderator
Posts: 8178
Joined: Sat 21. May 2005, 21:25
Location: HAMM (Germany)
Contact:

Re: article counter near category name (menu) in visitor page

Post 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
>> HowTo | DOCU | FAQ | TEMPLATES/DOCS << ( SITE )
User avatar
jsw_nz
Posts: 907
Joined: Fri 2. Apr 2004, 02:42
Location: New Zealand

Re: article counter near category name (menu) in visitor page

Post by jsw_nz »

cheers guys - will follow this thread....

:D
User avatar
Jensensen
Posts: 3000
Joined: Tue 17. Oct 2006, 21:11
Location: auf der mlauer

Re: article counter near category name (menu) in visitor page

Post by Jensensen »

I'm trying another solution that can be found here: http://forum.phpwcms.org/viewtopic.php?f=8&t=17891
{so_much} | Knick-Knack. | GitHub
Umlaute im URL sind meistens immer Kacke.
Post Reply