NLU_FF_AC_QD [update v.1.9.9]

Post custom hacks and enhancements for phpwcms here only. Maybe some of these things will be included in official release later.
User avatar
Jensensen
Posts: 3000
Joined: Tue 17. Oct 2006, 21:11
Location: auf der mlauer

NLU_FF_AC_QD [update v.1.9.9]

Post by Jensensen »

new version, new code, new stuff.

Whenever you need/want to display the number of articles of any site structure level next to the name of the category, the script does it.


This is the quick and dirty solution!
This is the original NAV_LIST_UL of flip-flop that was incorporated by OG and now has been extended with
--> easily add the number of articles within a certain site structure level.
https://github.com/slackero/phpwcms/com ... cc1dbfbebe
The script works exactly like NAV_LIST_UL [read more about basics]. You can use it with the same prominent parameters and features as usual.

Example of the menu:
Company (4)
Products (37)
Staff (12)

On the other hand it needs its own quick'n-dirty replacement tag
NLU_FF_AC_QD



You're able to edit the output of the source code to your needs:
(12) or [12] or -12 or what

Just edit
// Article Count Wrapper

$acw_before = " <span>(";
$acw_after = ")</span>";


Usage:

Code: Select all

{NLU_FF_AC_QD:FA,5,,count_articles,active}
Parent lift

Code: Select all

{NLU_FF_AC_QD:FPA,4,2,act_path,active}
new NAV_LIST_UL (since app_v1.4.4 r387 and higher)

Code: Select all

{NLU_FF_AC_QD:FA,3,10,act_path,active,,,,,.......}
Inline PHP

Code: Select all

[PHP] 
if(isset($GLOBALS['LEVEL_ID'][1])) {
	$level_id = $GLOBALS['LEVEL_ID'][1];
	echo '<div class="my_navi_with_the_number_of_articles_in_the_site_structure_level">';
	echo '{NLU_FF_AC_QD:FA,'.$level_id.',1,act_path,active}';
	echo '</div>';
}
[/PHP]

More information and Download:

https://github.com/jensensen/NLU_FF_AC_QD
Last edited by Jensensen on Mon 12. Feb 2024, 23:40, edited 20 times in total.
{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

NLU_FF_AC_QD [update v.1.1]

Post by Jensensen »

New for v1.4.1 (but should work with older versions as well / at least v1.3.x i would say).

v1.1 Improvements:
--> Now it works perfect also with unfolded menus.
--> minor errors fixed.


Keep in mind, that this script can be used the same way like using the original --> NAV_LIST_UL (based on the same function).
Just use this RT = replacement tag: 'NLU_FF_AC_QD'.

For those who are interested why I chose this name:
NLU = NAV_LIST_UL
FF = flip-flop
AC = article count
QD = quick and dirty

Needs a little bit of CSS as usual. :wink:

Limitations: There's one limitation only. The script only counts the number of articles which are in exactly the same site structure level that appears in the menu. There's no summation (unfolded) over all. Articles in sub-categories are ignored (in that way)!

Example:
Products (1 article)
-- Product_A (17 articles)
-- Product_B (3 articles)

Output:
Products (1)
Product_A (17)
Product_B (3)

YOU WON'T GET:
Products (21)
[know what i mean?]

Any FEEDBACK appreciated. Thank you!
Last edited by Jensensen on Fri 20. Nov 2009, 00:23, edited 1 time in total.
{so_much} | Knick-Knack. | GitHub
Umlaute im URL sind meistens immer Kacke.
User avatar
yorkshire_boy1
Posts: 17
Joined: Tue 26. Sep 2006, 13:35
Location: UK

Re: NLU_FF_AC_QD [update v.1.1]

Post by yorkshire_boy1 »

Hi Jensensen, great hack - many thanks for this.

I am currently building a site which uses the News Article feature, creating a series of news feeds based on tags that i add to the news articles. I am doing this so that i can add content once and it will appear in various places on the site depending on the tag. (I would prefer a tag system for normal articles of course, but this does not exist (yet!))

I have hacked your hack to allow me to count the number of news articles instead of regular articles. You name the page category the same as the news article tag you want to count.

Example:
Products (15 news article with tag Products)
ProductType1 (3 news articles with tag ProductType1)
ProductType2 (12 news articles with tag ProductType2)

Output:
Products (15)
--ProductType1 (3)
--ProductType2 (12)

When you click on a menu item, you just take the user to a news feed based on that tag.

I swapped your (or Flip Flops?) code which is here:

Code: Select all

// count number of articles in each category level
		
$sql = "SELECT * ";
$sql .= "FROM ".DB_PREPEND."phpwcms_article ";
$sql .= "WHERE article_cid=$key ";
$sql .= "AND article_public=1 AND article_aktiv=1";
with this new code:

Code: Select all

//count number of news articles which have a tag assigned equal to each category name

$sql = "SELECT ".DB_PREPEND."phpwcms_content.cnt_id, ".DB_PREPEND."phpwcms_categories.cat_pid ";
$sql .= "FROM ".DB_PREPEND."phpwcms_content JOIN ".DB_PREPEND."phpwcms_categories ";
$sql .= "ON ".DB_PREPEND."phpwcms_content.cnt_id = ".DB_PREPEND."phpwcms_categories.cat_pid ";
$sql .= "WHERE ".DB_PREPEND."phpwcms_content.cnt_status=1 ";
$sql .= "AND ".DB_PREPEND."phpwcms_categories.cat_name=(SELECT ".DB_PREPEND."phpwcms_articlecat.acat_name FROM ".DB_PREPEND."phpwcms_articlecat WHERE ".DB_PREPEND."phpwcms_articlecat.acat_id=$key)";
Maybe this will be useful to someone else.
User avatar
Oliver Georgi
Site Admin
Posts: 9908
Joined: Fri 3. Oct 2003, 22:22
Contact:

Re: NLU_FF_AC_QD [update v.1.1]

Post by Oliver Georgi »

Habe mal flink geschaut.

Es fehlen einige wesentliche Gültigkeitsabfragen für die zu zählenden Artikel.

Code: Select all

		// count number of articles in each category level
		$sql  = 'SELECT COUNT(*) FROM '.DB_PREPEND.'phpwcms_article ';
		$sql .= 'WHERE article_cid=' . $key . ' AND article_deleted=0 AND article_public=1 ';
		$sql .= 'AND article_aktiv=1 AND article_begin<NOW() AND ';
		$sql .= 'IF(article_archive_status=1, 1, article_end>NOW())';
Oliver Georgi | phpwcms Developer | GitHub | LinkedIn | Систрон
User avatar
Jensensen
Posts: 3000
Joined: Tue 17. Oct 2006, 21:11
Location: auf der mlauer

NLU_FF_AC_QD [update v.1.2]

Post by Jensensen »

habe mal ebenso flink nachgebessert
:== murks
{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: NLU_FF_AC_QD [update v.1.3]

Post by Jensensen »

The new version of phpwcms 1.4.4 r387 contains also a NEW Version of NAV_LIST_UL what requires an update of this very popular RT.

@OG: thank you!
btw a nice and new article menu navigation.

@flip-flop: sorry, i didn't want break off some links of the wiki.

@yorkshire_boy1:
Your code works perfect.
The idea of analyzing/counting of tags and using it as a base is really great!
Unfortunatly, the "tag system" works only with NEWS, as you said.
[could be a semantic approach, some kind of trigger, side-wide.]
It's an unbelievable feature - very cool - that was introduced by OG but also not considered in other ways. "(yet!)"

As far as I can see your SQL code does work with NEWS only.
It's really a perfect COUNTER for NEWS (and a great example for accessing NEWS in the database!).
What kind of RT did you use?


new version, new code, new stuff:
As well, this RT is fully compatiblel with the new NAV_LIST_UL.
For example, if you use 'FA', you'll get a list of site levels AND its articles (below).
Only site structure levels have (article_count) - that makes sense.
{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

NLU_FF_AC_QD [update v.1.4]

Post by Jensensen »

Once again, the new version of phpwcms 1.4.5 r397 contains a NEW Version of NAV_LIST_UL (func). That's why this very popular RT needs yet another update.
It's already for download {for friends, but not for greedy jiepers}

As always, you can use this RT the same way like you do with the well known NAV_LIST_UL.
[highly recommended] Use this script with phpwcms 1.4.5 and above.
Last edited by Jensensen on Tue 5. Feb 2013, 05:05, edited 1 time in total.
{so_much} | Knick-Knack. | GitHub
Umlaute im URL sind meistens immer Kacke.
User avatar
Oliver Georgi
Site Admin
Posts: 9908
Joined: Fri 3. Oct 2003, 22:22
Contact:

Re: NLU_FF_AC_QD [update v.1.4]

Post by Oliver Georgi »

Jensensen wrote:... contains a NEW Version of NAV_LIST_UL (func).
:wink: Not really new, a very little change.
Oliver Georgi | phpwcms Developer | GitHub | LinkedIn | Систрон
User avatar
Jensensen
Posts: 3000
Joined: Tue 17. Oct 2006, 21:11
Location: auf der mlauer

NLU_FF_AC_QD [update v.1.5]

Post by Jensensen »

Once again, the new version of phpwcms 1.4.7 403 contains a NEW Version of NAV_LIST_UL (func). For example, now, custom CSS classes can be applied for each site level.
That's why this very popular RT needs yet another update.
This download is for friends only.

Use this RT the same way like the well known NAV_LIST_UL.
[recommended] Use this script with phpwcms 1.4.7 and above.
Last edited by Jensensen on Tue 5. Feb 2013, 05:06, edited 1 time in total.
{so_much} | Knick-Knack. | GitHub
Umlaute im URL sind meistens immer Kacke.
User avatar
Oliver Georgi
Site Admin
Posts: 9908
Joined: Fri 3. Oct 2003, 22:22
Contact:

Re: NLU_FF_AC_QD [update v.1.5]

Post by Oliver Georgi »

remember, the newer NAV_LIST_UL can use articles as menu item too: try FA, PA, FPA
Oliver Georgi | phpwcms Developer | GitHub | LinkedIn | Систрон
User avatar
Jensensen
Posts: 3000
Joined: Tue 17. Oct 2006, 21:11
Location: auf der mlauer

NLU_FF_AC_QD [update v.1.51]

Post by Jensensen »

latest enhancements by: flip-flop {thank-you}
latest version: 1.51

cont'd:
[de] http://www.phpwcms-howto.de/wiki/doku.p ... icle-count
[en] http://www.phpwcms-howto.de/wiki/doku.p ... icle-count
{so_much} | Knick-Knack. | GitHub
Umlaute im URL sind meistens immer Kacke.
User avatar
update
Moderator
Posts: 6455
Joined: Mon 10. Jan 2005, 17:29
Location: germany / outdoor

Re: NLU_FF_AC_QD [update v.1.5]

Post by update »

HE is really back!
It's mostly all about maintaining two or three customer's sites Still supporter for the band Mykket Morton. Visit Mykket Morton on FB. Listen Mykket Morton and live videos on youtube.
Now building a venue for young artists to get wet on stage, rehearsal rooms, a studio, a guitar shop - yes I'm going to build some guitars.
User avatar
baklavoni
Posts: 170
Joined: Mon 23. Oct 2006, 00:48
Location: Bosnia and Herzegovina

Re: NLU_FF_AC_QD [update v.1.5]

Post by baklavoni »

Welcome back Jensensen!
:wink:

btw, nice RT!
There is no page like home page...
User avatar
Jensensen
Posts: 3000
Joined: Tue 17. Oct 2006, 21:11
Location: auf der mlauer

NLU_FF_AC_QD [update v.1.6]

Post by Jensensen »

NAV_LIST_UL, in my opinion, has been massively changed on April 7th, 2012 [r460 v1.5x+].

Due to perfect programming, old versions of the script works well even with newer versions of phpwcms.
Because of structural changes of NAV_LIST_UL in /include/inc_front/front.func.inc.php the script needs an update.

Have a look at:
https://github.com/slackero/phpwcms/com ... 2017febc9c
https://github.com/slackero/phpwcms/tre ... nc.inc.php

More information and Download:

https://github.com/jensensen/NLU_FF_AC_QD
{so_much} | Knick-Knack. | GitHub
Umlaute im URL sind meistens immer Kacke.
User avatar
update
Moderator
Posts: 6455
Joined: Mon 10. Jan 2005, 17:29
Location: germany / outdoor

Re: NLU_FF_AC_QD [update v.1.6]

Post by update »

It's always nice to read you :)
It's mostly all about maintaining two or three customer's sites Still supporter for the band Mykket Morton. Visit Mykket Morton on FB. Listen Mykket Morton and live videos on youtube.
Now building a venue for young artists to get wet on stage, rehearsal rooms, a studio, a guitar shop - yes I'm going to build some guitars.
Post Reply