PDA

View Full Version : [Addon] cinq's vbArticles Hack v2.0 - Show number of articles per category


DRJ
04-06-2005, 10:00 PM
A small addon to show the number of articles in each category.
This addon is for cinq's vbArticles Hack v2.0 (https://vborg.vbsupport.ru/showthread.php?t=74189)

Hack version 1.0

Files to edit: 1
articles.php

Templates to edit: 2
vbArticles_categorybit
vbArticles_childcatbit

Install instructions
===========================================

File Edits

articles.php

Find

$catlistbit='';
if(!empty($cat_cache))
{
foreach ($cat_cache[0] AS $parentcatrow)
{
$parentid = $parentcatrow["articles_categoryid"];
$catname = $parentcatrow["categoryname"];
$parentcat = $parentcatrow["parentcategory"];



Replace with

$catlistbit='';
if(!empty($cat_cache))
{
foreach ($cat_cache[0] AS $parentcatrow)
{
$parentid = $parentcatrow["articles_categoryid"];
$catname = $parentcatrow["categoryname"];
$parentcat = $parentcatrow["parentcategory"];
$cattotal = 0;
$catcount = $DB_site->query("
SELECT *
FROM " . TABLE_PREFIX . "articles_article
WHERE categoryid =$parentid
AND usersubmitted=0
And draft = 0
");
$cattotal = $DB_site->num_rows($catcount);


Find

if(!empty($cat_cache[$parentid]))
{
foreach ($cat_cache[$parentid] AS $subcatrow)
{
$subcatid=$subcatrow["articles_categoryid"];
$subcatname=$subcatrow["categoryname"];


Replace with

if(!empty($cat_cache[$parentid]))
{
foreach ($cat_cache[$parentid] AS $subcatrow)
{
$subcatid=$subcatrow["articles_categoryid"];
$subcatname=$subcatrow["categoryname"];
$cattotal = 0;
$catcount = $DB_site->query("
SELECT *
FROM " . TABLE_PREFIX . "articles_article
WHERE categoryid =$subcatid
AND usersubmitted=0
And draft = 0
");
$cattotal = $DB_site->num_rows($catcount);



End File Edits

Template Edits

vbArticles_categorybit

Replace existing code with this

<if condition="$parentcat==0"><br>
<a href="articles.php?action=viewcat&catid=$parentid"><span class="smallfont"><b>$catname</b></a> ($cattotal)</span>
</if>


vbArticles_childcatbit


Replace existing code with this

<li><span class="smallfont"><a href="articles.php?action=viewcat&catid=$subcatid">$subcatname</a> ($cattotal)</span></li>



End Template Edits

You can see a demo of this mod here: http://www.vbaexpress.com/forum/articles.php

Lee
04-07-2005, 05:47 PM
the 2 template edits are identical - am I missing something?

DRJ
04-07-2005, 05:53 PM
Copy/Paste error. I fixed it now. Thanks :)

Lee
04-07-2005, 05:54 PM
I have installed the hack as shown (without the 2nd template edit possibly) and here it is http://www.cruiselineforums.com/forum/cruisereviews.php?

It shows some () without numbers. Is this because I don't have the 2nd template edit done?

Thanks!

Lee
04-07-2005, 05:56 PM
Okay, now I have () on all categories and subs, but no numbers. Will this just pull in newly submitted articles?

Lee
04-07-2005, 06:07 PM
it is working now - thanks!

*clicks install*

nexialys
04-07-2005, 06:13 PM
would be good to be added to the next release instead of a hack... good work, i like precise counts!

DRJ
04-07-2005, 06:33 PM
Glad you got it working speedpro :)

Thanks nexialys :)

kall
04-07-2005, 07:38 PM
Da.

Gut! :)

I suggested this waaay back. Good stuff mr (mrs?) DRJ. :)

Viks
04-08-2005, 02:17 PM
very cool

DRJ
04-12-2005, 09:17 PM
Updated: It was updating the category totals for all articles in the category even if they were not approved yet. So we need an extra condition:

WHERE categoryid =$subcatid
AND usersubmitted=0

First post has the updated code.

Kohhal
04-19-2005, 11:16 AM
Nice addon installed.

Though, it seems to be including draft articles which are not publically available yet, bug?

DRJ
04-19-2005, 01:13 PM
We can add another condition to take care of that.

And draft = 0

Top post updated.

Thanks

Kohhal
04-19-2005, 02:57 PM
Updated, nice one :D