• Resolved Angela

    (@g33kg0dd3ss)


    Still using and loving the plugin!

    I was wondering if there was a way to reference the various other bits of a download’s information within the template page. I see in the included template files ways to get the download title, file name, file type, file size, short description, download count, version, and download link. I’ve been through the documentation, and the only way I see there to echo the post’s content is by using the download-data shortcode — and shortcodes don’t work on the DM template pages. 🙂

    In my case, I want to echo the download’s ID (to use in a bit of JavaScript) and the post_content, which will be where I store my release notes. None of the PHP code I’ve tried has worked for me:

    <?php $dlm_download->the_id(); ?>
    <?php echo $dlm_download->get_the_id(); ?>
    <?php $dlm_download->the_post_content(); ?>
    <?php echo $dlm_download->get_the_post_content(); ?>

    …etc, etc.

    Thanks in advance for any help you can provide!

    https://wordpress.org/plugins/download-monitor/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Angela

    (@g33kg0dd3ss)

    Nosing around in the code, I found that the plugins/download-monitor/includes/class-dlm-download.php houses all the functions used in the display of download details. There was no function that called post_content, so I made one!

    On line 157, between the functions for the_short_description and get_the_image, I added:

    /**
    	 * get_the_post_content function.
    	 *
    	 * @access public
    	 * @return void
    	 */
    	public function get_the_post_content() {
    		return wpautop( do_shortcode( $this->post->post_content ) );
    	}
    
    	/**
    	 * the_post_content function.
    	 *
    	 * @access public
    	 * @return void
    	 */
    	public function the_post_content() {
    		echo $this->get_the_post_content();
    	}

    I can do something similar for the download ID, but I think I might just extract it from the download link.

    Of course, none of this will survive the next plugin update, but hopefully it will make it into the next release. 😉 *poke poke*

    Plugin Contributor Barry Kooij

    (@barrykooij)

    Hey,

    Sorry for my delayed reply! If you want to access the download ID you can simply use $download->id. Adding methods to the DLM_Download class is not recommended as they will indeed be removed on update.

    Kind Regards,

    Barry Kooij

    Thread Starter Angela

    (@g33kg0dd3ss)

    Agreed, it’s not the best solution, but it was necessary for one of my clients’ site’s download templates. :-/ (Plus it’s now become useful in other sites where I’m using this plugin.)

    Thanks for the tip about $dlm_download->id (corrected from $download->id in your reply). Works like a charm!

    Any way the post_content bit will make it into a future release? It will definitely give custom templates a bit more flexibility; I’m using post_content and short_content in different ways in the same template. It’s also a bit confusing to have a big Post Content field on the Add Download page and not actually be able to reference its value in any way. 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Echo Additonal Download Details in DM Template’ is closed to new replies.