Zeka's post in Force pdf download was marked as the answer
Hi, Horst and thank you for answer.
For now i implement solution based on url segments.
<?php
if($input->urlSegment1 == 'download') {
if($input->urlSegment2) {
$names = array();
$urls = array();
foreach ($page->diagnostic_referral_repeater as $referral) {
foreach ($referral->diagnostic_referral_files as $file) {
array_push($names, $file->name);
array_push($urls, $file->filename);
}
}
$key = array_search($input->urlSegment2, $names);
if($key !== false) {
wireSendFile($urls[$key]);
} else {
throw new Wire404Exception();
}
}
} else if($input->urlSegment1) {
// unknown URL segment, send a 404
throw new Wire404Exception();
}
?>
<?php foreach ($page->diagnostic_referral_repeater as $referral) { ?>
<div class="diagnostic-referral">
<div class="diagnostic-referral__box">
<div class="diagnostic-referral__title">
<?php echo $referral->diagnostic_referral_category->title; ?>
</div>
<?php echo $referral->render('diagnostic_referral_files', 'diagnostic-referral'); ?>
<div class="diagnostic-referral__files">
<?php foreach ($referral->diagnostic_referral_files as $file) { ?>
<div class="diagnostic-referral-file">
<a href="<?php echo $page->path.'download/'.$file->name; ?>" class="diagnostic-referral-file__link">
<div class="diagnostic-referral-file__icon">
<span class="icon-download"></span>
</div>
<div class="diagnostic-referral-file__title">
<?php echo $file->description; ?>
</div>
</a>
</div>
<?php } ?>
</div>
</div>
</div>
<?php } ?>
Do you have any recommendation to improve it?
Thanks.