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