We provide downloadable E copys of each issue to subscribers in several formats… epub, mobi, html-zip, etc. We store those in DLM as versions. We wanted the download page to show the issuem cover image for each issue, along with the versions, without requiring our editorial staff to re-connect the image to that issues downloads.
You can see an image of the resulting download archive page at https://grantvillegazette.com/wp/wp-content/uploads/2019/02/DLM_page.png We’re pretty proud of it.
The template is in our theme’s child-theme in a download-monitor directory as download-content-fancy and is called with a shortcode [downloads loop_start='<div class=dlm_custom_shortcode>’ loop_end='</div>’ before='<span>’ after='</span>’ orderby=title order=DESC template=fancy]
Figuring this out was not trivial. DLM’s documentation of custom templates, and of the various functions inside DLM is not rich, however this sort of thing is possible.
It’s certainly true that the code in the template could be improved on, it’s pretty much a hack, but there are so few posts in this forum about successes that I thought it would be good to share one.
So, with excuses about quality etc. here’s the code.
<?php
if (!defined('ABSPATH')) {
exit;
}
/** @var DLM_Download $dlm_download */
$dlTitle = $dlm_download->get_title();
$mySlug = 'gg-0' . str_ireplace('Grantville Gazette Volume ','',$dlTitle);
echo '<div id="' . $mySlug . '" class="dlm_custom_download"><p>';
$issueArgs = array(
'taxonomy' => 'issuem_issue',
'slug' => $mySlug,
);
$theseIssues = new WP_Term_Query($issueArgs);
foreach ($theseIssues->terms as $thisIssue) {
$issue_meta = get_option( 'issuem_issue_' . $thisIssue->term_id . '_meta' );
$myCover = wp_get_attachment_image_src( $issue_meta['cover_image'], array(138, 220,));
echo '<img class="attachment-issuem-cover-image size-issuem-cover-image" alt="Cover for '. $mySlug . '-" src="' . $myCover[0] . '"><br>';
echo str_ireplace('Grantville Gazette ','',$dlTitle) . "<br></p>";
}
$versions = $dlm_download->get_versions();
if ( count( $versions ) < 1 ) {
echo 'No versions found.';
} else {
foreach ( $versions as $version ) {
// get the versions meta-data into a variable
$thisVersion = $dlm_download->get_version( $version );
// now, build a NEW array we can sort on the version number (rtf, html, epub, mobi)
// consisting of key->value pairs of version_number->downloadURL
$versionList[$version->get_version_number()] = $dlm_download->get_the_download_link(array( version => $thisVersion, )) ;
}
// now, sort that new array by its keys, so it goes into consistent order.
ksort($versionList);
// now, loop through the sorted array and build the links to each version
while ($dlLink = current($versionList)) {
echo ' <a class="download-link" href="' . $dlLink . '?version=' . key($versionList) . '" rel="nofollow">';
echo key($versionList) . '</a> ';
next($versionList);
}
echo '</div>';
}
]]>[download]
shortcode.
Can you please tell us what code/template tag to use to get the file upload date? Using the template tags from the [download_data]
shortcode doesn’t work.
thanks!
https://www.ads-software.com/support/plugin/download-monitor
]]>any chance to make the author metabox available for the “download monitor” plugin?
It is available for all sites and pages but not for this kind of posts (“dlm_download”)
All the best,
John
]]>When I go to the backend through FTP the file is present in the uploads/2017/07 folder. But when I go to dlm_uploads the 07 folder is missing (06 and 08 do exist).
Can someone tell me what is the cause of this problem?
I have seen this happening before on my own site. This was also in July (=07).
I found the information, that Polylang and Download Monitor are not compatible. But no soloution.
For my private blog there might be an very easy workaround, but I don’t get it working.
Workaround Goal:
Instead of https://domain.tld/download/123
I want to link to
https://domain.tld/en/download/123
I don’t need a difference of the langauges in the download-link and it works with any used language (de, fr …)
I can think of three aproches and an last resort.
1. custom download format
add a content-download-websitename.php to the theme-folder and adjust the code.
<a class="download-link" href="<?php $dlm_download->the_download_link(); ?>" rel="nofollow">
no idea how :/
2. functions.php
no idea where to start at all.
3. .htaccess redirect.
my idea was
Options +FollowSymLinks
RewriteEngine On
rewriterule ^download/(.*)$ https://domain.tld/en/download/$1 [r=301,nc]
but it didn’t work
last resort:
manually set ink in the editor.
<a href="https://domain.tld/en/download/123">Button-Text</a>
I just almost don’t need the plugin than
thanks for your help and hints you might have for me.
Kristof
]]>https://www.ads-software.com/plugins/download-monitor/
]]>I see how the files are linked differ somewhat, as it appears to use PHP to re-direct the download link to where the file is actually uploaded.
For example, when copying the File URL from a particular download, then pasting into a browser, it’ll find the file.
If you follow the Download link from the front-end, it just adds the Download Endpoint + Endpoint Value to the site’s root URL and does not find the file.
I feel like I’m looking at this in too much depth, and the solution is very simple but I’m overlooking. Any advice here would be greatly welcomed!
Cheers
https://www.ads-software.com/plugins/download-monitor/
]]>DLM conflicts with NGG’s legacy syntax for its SinglePic, so the following breaks:
[singlepic=18,450,693,,]
and the error message shown reads: ‘[SinglePic not found]’
But this does not:
[singlepic id=18 w=450 h=693 float=center]
I am currently in the process of manually updating all my NGG legacy syntax.
https://www.ads-software.com/extend/plugins/download-monitor/
]]>