Seite 1 von 1

How to get a number of files in a directory ?

Verfasst: So 1. Mär 2020, 04:13
von kubasaw
Hi,
I would like to know how to get a number of documents in any given directory.

Is it possible to filter this number by category of document ?

Thank you in advance for any help.

Jacob

Re: How to get a number of files in a directory ?

Verfasst: So 1. Mär 2020, 11:58
von Finn
Hey Jacob,
you can use a listview to count all Documents in a directory.

Like that:

Code: Alles auswählen

<we:listview type="document" name="document_count" workspaceID="217" searchable="false">
	<we:repeat>
		<we:ifPosition position="last" type="listview"><we:position type="listview" format="1" /></we:ifPosition>
	</we:repeat>
</we:listview>
If you just want to count files with searchable true, just change it. You can also add "contenttypes" for special kind of files or add "categoryids" for counting just one or more categorys.

Hope it helps!

Finn

Re: How to get a number of files in a directory ?

Verfasst: So 1. Mär 2020, 17:12
von kubasaw
Thanks a lot !
I am still a beginner, using webEdition sporadically on rather basic level, but I am always amazed by the universality of this system.
A lot of things to discover !

Have a nice day !

Jacob

Re: How to get a number of files in a directory ?

Verfasst: So 1. Mär 2020, 20:55
von ThomasGoebe
No need to start a we:repeat, imho

Code: Alles auswählen

<we:listview type="document" name="document_count" workspaceID="217" searchable="false">
	<we:listviewRows />
</we:listview>
should work also.

And if you want to use the number in a variable:

Code: Alles auswählen

<we:listview type="document" name="document_count" workspaceID="217" searchable="false">
	<we:listviewRows to="global" nameto="found_items" />
</we:listview>

...

<we:var type="global" name="found_items" /> items found.
Use we:ifFound to check, if there are any documents:

Code: Alles auswählen

<we:listview type="document" name="document_count" workspaceID="217" searchable="false">
	<we:ifFound>
		<we:listviewRows /> items found.
	<we:else />
		No items found.
	</we:ifFound>
</we:listview>

Re: How to get a number of files in a directory ?

Verfasst: Mo 2. Mär 2020, 03:50
von kubasaw
Thanks a lot, Thomas !

I appreciate a lot !

Jacob