Kirby helper: files only name

Hello,

how to get only the file names without extension ?

$page->files()->filterBy(‘type’, ‘video’)->name

my first controller :flashlight:

<?php


return function($site, $pages, $page) {

	$indexData = array();

	foreach ($page->files()->filterBy('type', 'video') as $child) {
	$indexData[] = $child;
	
	}


	$video_collection_count = $page->files()->filterBy('extension', 'mp4')->count();
	$random = rand(0,$video_collection_count-1);

  return array(
  'output' => $indexData[$random]
  );

};

?>

please look at $file->name() for details

https://getkirby.com/docs/cheatsheet/file/name

$file->name() returns the file name without the extension, but note that you can only use this method with a single file, not with a collection of files as in this code $page->files()->filterBy('type', 'video')->name

foreach( $page->files()->filterBy('type', 'video') as $file) {
  $indexData[] = $file->name();
}

thank you @texnixe:slight_smile: