How to get a number of files in a directory ?

basic functions and we:tags
kubasaw
Junior Member
Beiträge: 8
Registriert: Fr 19. Sep 2014, 13:00

How to get a number of files in a directory ?

Beitragvon kubasaw » So 1. Mär 2020, 04:13

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

Benutzeravatar
Finn
Member
Beiträge: 81
Registriert: Mo 3. Apr 2017, 13:37
Wohnort: Bremen
Kontaktdaten:

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

Beitragvon Finn » So 1. Mär 2020, 11:58

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
Finn Thorwarth
WG Werbeagentur
https://www.wg-werbeagentur.de

kubasaw
Junior Member
Beiträge: 8
Registriert: Fr 19. Sep 2014, 13:00

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

Beitragvon kubasaw » So 1. Mär 2020, 17:12

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

ThomasGoebe
Senior Member
Beiträge: 865
Registriert: Mo 26. Jul 2010, 23:44
Wohnort: Hannover
Kontaktdaten:

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

Beitragvon ThomasGoebe » So 1. Mär 2020, 20:55

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>
Thomas Göbe
webEdition Experte aus Hannover
Autor des 1. webEdition Buch (gemeinsam mit Andreas Witt)
web: http://www.projektheimat.de

kubasaw
Junior Member
Beiträge: 8
Registriert: Fr 19. Sep 2014, 13:00

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

Beitragvon kubasaw » Mo 2. Mär 2020, 03:50

Thanks a lot, Thomas !

I appreciate a lot !

Jacob


Zurück zu „Creating templates“

Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 1 Gast