Implement Error for nothing found

This commit is contained in:
seiichiro 2022-01-10 15:47:35 +01:00
parent 5650d15de0
commit 12f9149ca9
2 changed files with 47 additions and 31 deletions

View file

@ -58,6 +58,8 @@ $files = array_reverse($files);
// Get Files for current Page // Get Files for current Page
$curfiles = array_slice($files, ($page-1)*$slice ,$slice, true); $curfiles = array_slice($files, ($page-1)*$slice ,$slice, true);
if (count($curfiles > 0)) {
// Prepare Generic Data for Template // Prepare Generic Data for Template
$data['dir'] = $dir; $data['dir'] = $dir;
$data['slice'] = $slice; $data['slice'] = $slice;
@ -74,7 +76,6 @@ $data['last_page'] = ceil(count($files)/$slice);
// Prepare Mode Specific Data and Render Template // Prepare Mode Specific Data and Render Template
if ($slice > 1) { if ($slice > 1) {
foreach ($curfiles as $index => $image) { foreach ($curfiles as $index => $image) {
print_r($image."\n");
$tmp['n'] = $image; $tmp['n'] = $image;
$tmp['i'] = $index+1; $tmp['i'] = $index+1;
$tmp['t'] = $thumburl.$t->get_thumb($image); $tmp['t'] = $thumburl.$t->get_thumb($image);
@ -89,9 +90,12 @@ if ($slice > 1) {
$data['imagename'] = $image; $data['imagename'] = $image;
$data['tags'] = explode(" ", pathinfo(trim(strstr(strtolower($image), ' - '), " -"))['filename']); $data['tags'] = explode(" ", pathinfo(trim(strstr(strtolower($image), ' - '), " -"))['filename']);
} }
Template::view('tpl/single.html', $data); Template::view('tpl/single.html', $data);
} }
} else {
$data['filter'] = substr($filter,2);
$data['script'] = $_SERVER['PHP_SELF'];
Template::view('tpl/notfound.html', $data);
}
?> ?>

12
tpl/notfound.html Normal file
View file

@ -0,0 +1,12 @@
{% extends tpl/layout.html %}
{% block title %}Nothing found{% endblock %}
{% block content %}
<div class="content">
<p class="error">Nothing found with search term {{ $filter }}</p>
<p class="error">Return to <a href="{{ $script }}">Homepage</a></p>
</div>
{% endblock %}