Jump to content

Zeka

Members
  • Posts

    1,065
  • Joined

  • Last visited

  • Days Won

    11

Community Answers

  1. Zeka's post in [SOLVED] Redirect on "Save + Exit" / Hook for "Save + Exit" action was marked as the answer   
    LostKobrakai, thanks for help!
    Final solution
    wire()->addHookBefore("ProcessPageEdit::processSaveRedirect", function(HookEvent $event) { $url = $event->arguments(0); $page = $event->object->getPage(); if($page->template->name == 'blog-entry') { if($url == "../") { $goto = wire("pages")->get(3062)->url; $event->arguments = array($goto); } } });
  2. 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. 
×
×
  • Create New...