Audio Download on or off

amwproductions
@amwproductions
7 years ago
185 posts
Hello how i can create with the from designer a checkbocx to enable or disable downloads?

I have a problem....

A lot of my users would be offer free download of the audio files, and other users would disable it for copyright motive

Ca one me help?


updated by @amwproductions: 07/24/17 03:30:58AM
michael
@michael
7 years ago
7,746 posts
These solved questions seam related:
https://www.jamroom.net/the-jamroom-network/forum/new_posts/48645/block-audio-download-for-guests
https://www.jamroom.net/the-jamroom-network/forum/new_posts/33671/how-to-allow-free-audio-file-downloads-only-to-logged-in-members/search_string=downloads

An plan for what you are wanting to is:
* Use the Form Designer to add a checkbox to the CREATE/UPDATE form of the audio module.
* Edit the templates to adjust the download button to show or not show based on whether that checkbox is checked.
amwproductions
@amwproductions
7 years ago
185 posts
michael:
These solved questions seam related:
https://www.jamroom.net/the-jamroom-network/forum/new_posts/48645/block-audio-download-for-guests
https://www.jamroom.net/the-jamroom-network/forum/new_posts/33671/how-to-allow-free-audio-file-downloads-only-to-logged-in-members/search_string=downloads

An plan for what you are wanting to is:
* Use the Form Designer to add a checkbox to the CREATE/UPDATE form of the audio module.
* Edit the templates to adjust the download button to show or not show based on whether that checkbox is checked.

Hi michael tnx, how we edit the template have you an example?
amwproductions
@amwproductions
7 years ago
185 posts
Hi michael, thank you for your help. I already have done those steps with checkbox into the form designer, the problem is, even if the checkbox is activated, there is still the possibility to download. Can you please tell me the code which I have to integrate into the template?

Thx a lot
Kurt
michael
@michael
7 years ago
7,746 posts
Adding a checkbox will make nothing different on your site. Its just a checkbox. What it will do is when you look at the details for that audio item, you will have a new variable and it will either be 'on' or 'off'.

You can use {debug} in the template you're interested in to see if that checkbox is there or not.

Docs: "{debug}"
https://www.jamroom.net/the-jamroom-network/documentation/module-developer-guide/1477/debug

In the template where the download button is shown it will be shown because of this line:
{jrCore_item_detail_buttons module="jrAudio" field="audio_file" item=$item}

You want to check the state of your checkbox, then hide/show the button from there.

Example, if you wanted to turn off the audio download button you could use this code

{jrCore_item_detail_buttons module="jrAudio" field="audio_file" item=$item exclude="jrAudio_item_download_button"}

and the button wont show, so to check the state of your checkbox first, then

{$ex_dl = ''}
{if isset($item.audio_download_checkbox) && $item.audio_download_checkbox == "off"}
   {$ex_dl = 'jrAudio_item_download_button'}
{/if}
{jrCore_item_detail_buttons module="jrAudio" field="audio_file" item=$item exclude=$ex_dl}


^^ in that code above im guessing at what you called your checkbox. I dont know if you called it 'audio_download_checkbox' or not in the Form Designer. Use the name you called it.
updated by @michael: 04/20/17 07:36:23PM
amwproductions
@amwproductions
7 years ago
185 posts
Hi @michael sorry i am not able to set see images

to me changes notting the templates to edit i have found item_detail.tpl and item_index.tpl

{jrCore_module_url module="jrAudio" assign="murl"}





{jrCore_item_index_buttons module="jrAudio" profile_id=$_profile_id}


{if isset($_post._1) && strlen($_post._1) >0}{$_post._1}{else}{jrCore_lang module="jrAudio" id="41" default="Audio"}{/if}
{$profile_name} ยป {jrCore_lang module="jrAudio" id="41" default="Audio"}




{jrCore_list module="jrAudio" profile_id=$_profile_id order_by="audio_display_order numerical_asc" pagebreak="6" page=$_post.p pager=true}
{* allow downloads if we are not blocked *}
{if isset($_conf.jrAudio_audio_block_download) && $_conf.jrAudio_audio_block_download == 'off'}
{jrCore_icon icon="download"}
{/if}
{$ex_dl = ''}
{if isset($item.audio_download_checkbox) && $item.audio_download_checkbox == "off"}
{$ex_dl = 'jrAudio_item_download_button'}
{/if}
{jrCore_item_detail_buttons module="jrAudio" field="audio_file" item=$item exclude=$ex_dl}




example of item_index.tpl i have changed?

Tags