Hi, I’m almost positive this is something easy to do, but my knowledge of PHP is somewhat limited so help would be appreciated. I have some code that looks like this:
I’m basically automatically pulling, from a separate directory, a manual PDF whose filename matches the pageid of the current page. It works so far, but only if the corresponding PDF is present. If it’s not, or misspelled, nearly the entire page fails to load. Can someone help me make this display a broken link or something more useful than simply breaking the page? Also if I’m just doing this in a weird way that would be good to know
The $manualfilename variable is now using $page->slug() instead of $page->pageid() and I used a Kirby helper e() to run an if/else statement that echo’s the results. You may also wish to wrap the whole url in the e() helper (and remove the false string) instead, so the link will only show up if the file exists.