phseven Posted January 28, 2021 Share Posted January 28, 2021 Is there an option to limit video downloads to premium users? Right now is possible to limit download to video formats but not to premium users. Quote Link to comment Share on other sites More sharing options...
Tech Support Posted January 29, 2021 Share Posted January 29, 2021 Yes, it is possible but not via settings, but via template. In Website UI -> Pages -> View Video page -> video_view block template there is the following code to render download links: {{foreach item="item" from=$data.download_formats}} {{assign var="format_lang_key" value=$item.postfix|replace:".":"_"}} <a href="{{$item.file_url}}" data-attach-session="{{$session_name}}">{{$lang.videos.video_details_label_download_format[$format_lang_key]|default:"%1%, %2%"|replace:"%1%":"`$item.title`"|replace:"%2%":$item.file_size_string}}</a> {{/foreach}} What you should do is change this: href="{{$item.file_url}}" with this: {{if $smarty.session.status_id==3}}href="{{$item.file_url}}"{{elseif $smarty.session.user_id>0}}href="{{$lang.urls.upgrade}}" data-fancybox="ajax"{{else}}href="{{$lang.urls.login_required}}" data-fancybox="ajax"{{/if}} So KVS will still display download links, but if non-premium user clicks this link there will be either login dialog (user is not logged in), or upgrade dialog (user is not premium status) displayed. 3 Quote Link to comment Share on other sites More sharing options...
Emilia Posted January 29, 2021 Share Posted January 29, 2021 Hi, what would be the code if I want to enable downloads for logged in members only? Quote Link to comment Share on other sites More sharing options...
Tech Support Posted January 29, 2021 Share Posted January 29, 2021 26 minutes ago, Emilia said: Hi, what would be the code if I want to enable downloads for logged in members only? Should be: {{if $smarty.session.user_id>0}}href="{{$item.file_url}}"{{else}}href="{{$lang.urls.login_required}}" data-fancybox="ajax"{{/if}} 1 Quote Link to comment Share on other sites More sharing options...
Emilia Posted January 29, 2021 Share Posted January 29, 2021 Hi, it didn't work for me. here's my snippet {{foreach item="item" from=$data.download_formats}} {{assign var="format_lang_key" value=$item.postfix|replace:".":"_"}} <a href="{{$item.file_url}}&download_filename=mysite_{{$data.dir}}{{$item.postfix}}" data-attach-session="{{$session_name}}">{{$lang.videos.video_details_label_download_format[$format_lang_key]|default:"%1%, %2%"|replace:"%1%":"`$item.title`"|replace:"%2%":$item.file_size_string}}</a> {{/foreach}} Quote Link to comment Share on other sites More sharing options...
davex Posted January 29, 2021 Share Posted January 29, 2021 Thanks! 😉 Quote Link to comment Share on other sites More sharing options...
Tech Support Posted January 30, 2021 Share Posted January 30, 2021 13 hours ago, Emilia said: here's my snippet But it doesn't have the code that we specified... Quote Link to comment Share on other sites More sharing options...
Emilia Posted January 30, 2021 Share Posted January 30, 2021 6 hours ago, Tech Support said: But it doesn't have the code that we specified... Yes, can you tell me where to put it? It broke when i did it Quote Link to comment Share on other sites More sharing options...
Tech Support Posted January 30, 2021 Share Posted January 30, 2021 25 minutes ago, Emilia said: Yes, can you tell me where to put it? It broke when i did it Here: <a {{if $smarty.session.user_id>0}}href="{{$item.file_url}}&download_filename=mysite_{{$data.dir}}{{$item.postfix}}"{{else}}href="{{$lang.urls.login_required}}" data-fancybox="ajax"{{/if}} data-attach-session="{{$session_name}}">{{$lang.videos.video_details_label_download_format[$format_lang_key]|default:"%1%, %2%"|replace:"%1%":"`$item.title`"|replace:"%2%":$item.file_size_string}}</a> Should not brake anything. 1 1 Quote Link to comment Share on other sites More sharing options...
Tanjiro Posted August 21, 2023 Share Posted August 21, 2023 On 1/29/2021 at 12:36 PM, Tech Support said: Yes, it is possible but not via settings, but via template. In Website UI -> Pages -> View Video page -> video_view block template there is the following code to render download links: {{foreach item="item" from=$data.download_formats}} {{assign var="format_lang_key" value=$item.postfix|replace:".":"_"}} <a href="{{$item.file_url}}" data-attach-session="{{$session_name}}">{{$lang.videos.video_details_label_download_format[$format_lang_key]|default:"%1%, %2%"|replace:"%1%":"`$item.title`"|replace:"%2%":$item.file_size_string}}</a> {{/foreach}} What you should do is change this: href="{{$item.file_url}}" with this: {{if $smarty.session.status_id==3}}href="{{$item.file_url}}"{{elseif $smarty.session.user_id>0}}href="{{$lang.urls.upgrade}}" data-fancybox="ajax"{{else}}href="{{$lang.urls.login_required}}" data-fancybox="ajax"{{/if}} So KVS will still display download links, but if non-premium user clicks this link there will be either login dialog (user is not logged in), or upgrade dialog (user is not premium status) displayed. Luckily I found this topic, I was intend to create a new topic to ask exactly like this topic, how to enable download to only logged in members, thank you Quote Link to comment Share on other sites More sharing options...
Tanjiro Posted August 22, 2023 Share Posted August 22, 2023 May I ask what's the difference between: {{if $smarty.session.user_id>0}}href="{{$item.file_url}}"{{else}}href="{{$lang.urls.login_required}}" data-fancybox="ajax"{{/if}} And <a {{if $smarty.session.user_id>0}}href="{{$item.file_url}}&download_filename=mysite_{{$data.dir}}{{$item.postfix}}"{{else}}href="{{$lang.urls.login_required}}" data-fancybox="ajax"{{/if}} data-attach-session="{{$session_name}}">{{$lang.videos.video_details_label_download_format[$format_lang_key]|default:"%1%, %2%"|replace:"%1%":"`$item.title`"|replace:"%2%":$item.file_size_string}}</a> Which one should I use or is it the same? Quote Link to comment Share on other sites More sharing options...
Tech Support Posted August 22, 2023 Share Posted August 22, 2023 3 hours ago, Tanjiro said: May I ask what's the difference between: The 2nd one adds download filename parameter which looks like this: &download_filename=mysite_{{$data.dir}}{{$item.postfix}} You can use it, but worth changing "mysite" to your site name. Then the downloaded video file will have mysite_video-name.mp4 filename. 1 Quote Link to comment Share on other sites More sharing options...
viper Posted February 29 Share Posted February 29 On 1/29/2021 at 7:05 PM, Emilia said: Hi, what would be the code if I want to enable downloads for logged in members only? How can I do this? Please tell me step-by-step Quote Link to comment Share on other sites More sharing options...
Tech Support Posted February 29 Share Posted February 29 The discussion above contains all the info. Quote Link to comment Share on other sites More sharing options...
viper Posted February 29 Share Posted February 29 On 1/29/2021 at 7:32 PM, Tech Support said: Should be: {{if $smarty.session.user_id>0}}href="{{$item.file_url}}"{{else}}href="{{$lang.urls.login_required}}" data-fancybox="ajax"{{/if}} where i put this code? Quote Link to comment Share on other sites More sharing options...
Tech Support Posted February 29 Share Posted February 29 Please see 2nd post in this topic: Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.