jDownloads Support Forum

Older Versions => jDownloads 3.2 (Support ended) => Topic started by: walkout on 07.08.2015 07:19:33

Title: Need help redirecting to login page for user notloggedin to download file.
Post by: walkout on 07.08.2015 07:19:33
Hi ,
I am using jdownload , on my portal Everything seems to be working fine. I have enabled direct download for only logged in users to download File.

I am trying to find a way , so i can link the text "Only registered and logged in users can download this file" to login / register page , when guest tries to download the file.

Can someone point me in the right direction as to how i could accomplish this?


Ritesh
Title: Re: Need help redirecting to login page for user notloggedin to download file.
Post by: ColinM on 07.08.2015 13:26:34
Ritesh
That sounds like a nice idea but it is not straight forward to achieve.  Part of the problem is that the text "Only registered and logged in users can download this file" is part of the site language file. Specifically it is the TEXT Identifier COM_JDOWNLOADS_FRONTEND_FILE_ACCESS_REGGED which in the English file is "Only registered and logged in users can download this file."  If you are familiar with HTML and have a suitable link then you could edit the text to read something like
COM_JDOWNLOADS_FRONTEND_FILE_ACCESS_REGGED="Only registered and logged in users can download this file. <a href=your link info >Click here to logon</a>"

However that would possibly change on an update, and would need doing for every language.  One could of course modify the source code but again that could be an update problem.

To implement fully it would mean having a configuration parameter that requested the target link.
Perhaps you should put in suggestions

Colin
Title: Re: Need help redirecting to login page for user notloggedin to download file.
Post by: walkout on 07.08.2015 19:09:24
Hi Colin,
Thanks for your prompt responce. This is a required on one of my website http://1specialplace.com/drift-away-sail-boat.html

I was looking into extension code , and modifying it , Didnt realise there is a simpler way ;D

Thanks I will put in the suggestions section.
Title: Re: Need help redirecting to login page for user notloggedin to download file.
Post by: walkout on 10.09.2015 10:55:44
A Simple fix for my problem.

I am using Modules Anywhere , Instead of Displaying text message and hyperlink to register page I was able to insert a custom module.

Reference page could be seen at http://1specialplace.com/drift-away-sail-boat.html

Also , PS: This is a code hack and if upgraded you will loose the modifications.

You can modify the files JText::_('COM_JDOWNLOADS_FRONTEND_FILE_ACCESS_REGGED')

to JHTML::_('content.prepare', '{module modulename}'))

Files To be modified -
(1) Plugin / content / jdownloads.php file line -1147
Replace
$first_reg_msg = '<div class="jdpf_not_logged_in">'.JText::_('COM_JDOWNLOADS_FRONTEND_FILE_ACCESS_REGGED').'</div>';
with
$first_reg_msg = '<div class="jdpf_not_logged_in">'.JHTML::_('content.prepare', '{module custom login}')).'</div>';

(2) components/com_jdownloads/views/download/tmpl/default.php
Line - 673
Replace
$regg = JText::_('COM_JDOWNLOADS_FRONTEND_FILE_ACCESS_REGGED');
with
$regg =JHTML::_('content.prepare', '{module custom login}'));


(3) components/com_jdownloads/views/downloads/tmpl/default.php

Line - 1138
Replace
$regg = str_replace('
', '', JText::_('COM_JDOWNLOADS_FRONTEND_FILE_ACCESS_REGGED'));

With

$regg = str_replace('
', '', JHTML::_('content.prepare', '{module custom login}'));

Hope it helps

Thanks
Ritesh
Title: Re: Need help redirecting to login page for user notloggedin to download file.
Post by: ColinM on 10.09.2015 12:37:28
Hi
Yes that is a neat solution - and it is minimally invasive of the core code.  Does your custom module know if the user is logged in already?

With a bit more effort in you custom module you could get a regular looking button like attached

Colin

[gelöscht durch Administrator]