Fog Creek Software
Discussion Board




Knowledge Base
Documentation
Terry's Tips
Darren's Tips

Counting the number of articles

Recently I located a very simple Javascript that counted the number of files in a folder.  It worked great but I've misplaced it and can't find it again on the internet.

Does anyone know where it can be found?

Dennis Harwood
Monday, January 26, 2004

Here's one that works to count all the articles in a site.

<script language="javascript" type="text/javascript">
//<![CDATA[
<!--
var tmp = "{$ foreach x in (all) $}.{$ next $}";
if (tmp.length==0)
{
document.write(" currently no articles on this site.<br>");
} else
{
document.write("currently ",tmp.length," articles on this site.<br>");
}
//-->//]]>
</script>

tk
Monday, January 26, 2004

Thanks tk,

  It works great!  I like that it's based on the typical CD foreach command so I can tailor it to specific folders.  I'm setting up categories of articles (and an alpha list) and wanted to be able to let people know how many are in each one before clicking on them.

Dennis Harwood
Monday, January 26, 2004

Is there any way to pass a CD Variable to this script? I'm trying to use .extra1 or some other variable to setup a generic script to count files in specific folders but CD won't see things correctly.

Dennis Harwood
Monday, January 26, 2004

*  Recent Topics

*  Fog Creek Home