dario

[Solved 6r] BT Content Slider - Redirect login to the selected article

7 posts in this topic

Hi all,

I'm using BT Content Slider (very good extension) for showing articles preview to the visitors (not logged in)

These articles are for registered visitors only.

I corrected a first problem (404 page) modifing the content.php file from

$item->link = JRoute::_('index.php?option=com_user&view=login');

to

$item->link = JRoute::_('index.php?option=com_users&view=login');

Now the login page redirect to the home page and not to the selected article.

I'd like the link to the article that was similar to the following:

www.mysite.it/news/login?return=L25vdGl6aWUvMzItZ3JhbmRpLW...etc..=

where "=L25vdGl6aWUvMzItZ3JhbmRpLW...etc..=" is the BASE64 encoded address of the article

Can you help me?

Thanks

Dario

Share this post


Link to post
Share on other sites

Hi

Please try to use this solution

Open file /mod_bt_contentslider/classes/content.php

Find and change this block

if ($access || in_array($item->access, $authorised)) {
// We know that user has the privilege to view the article
//Item link
if($use_linka && $item->urls){
$item->urls = json_decode($item->urls);
$item->link = $item->urls->urla;
}
if(!$item->link) $item->link = JRoute::_(ContentHelperRoute::getArticleRoute($item->slug, $item->catslug));
}
else {

$item->link = JRoute::_('index.php?option=com_user&view=login');
}

to this

if (!$access || !in_array($item->access, $authorised)) {
$item->link = JRoute::_('index.php?option=com_user&view=login&return=' . base64_encode($item->link));
}

And you must set Access permission for your articles by registered.

Share this post


Link to post
Share on other sites

Hi and thanks for your reply.

I've tried to replace the code but it did not work.

So I've added "s" character to the "user" and the component started to work.

$item->link = JRoute::_('index.php?option=com_users&view=login&return='.base64_encode($item->link));

Last problem is that the

base64_encode($item->link)

is not added to the url string

The url is like this:

www.mysite.it/login?return=

url Base64 is missing

Share this post


Link to post
Share on other sites

Opps.

My mistake when copy the code from my local source.

The new code should be


if($use_linka && $item->urls){
$item->urls = json_decode($item->urls);
$item->link = $item->urls->urla;
}
if(!$item->link) $item->link = JRoute::_(ContentHelperRoute::getArticleRoute($item->slug, $item->catslug));
if (!$access || !in_array($item->access, $authorised)) {
$item->link = JRoute::_('index.php?option=com_users&view=login&return=' . base64_encode($item->link));
}

Share this post


Link to post
Share on other sites

Thanks Mod for your help.

I've tryed to insert your code but the modify didn't.

I mean, login redirect worked properly, but when logged, all links of the component were Base64 and not human friendly.

I have solved joining your previous code with the last one.

This is the code: (if there are errors, please correct them)


// item link
$item->link = '';
if ($access || in_array($item->access, $authorised)) {
// We know that user has the privilege to view the article
//Item link
if($use_linka && $item->urls){
$item->urls = json_decode($item->urls);
$item->link = $item->urls->urla;
}
if(!$item->link){
$item->link = JRoute::_(ContentHelperRoute::getArticleRoute($item->slug, $item->catslug));
}
}
else if(!$access || !in_array($item->access, $authorised)) {
if($use_linka && $item->urls){
$item->urls = json_decode($item->urls);
$item->link = $item->urls->urla;
}
if(!$item->link){
$item->link = JRoute::_(ContentHelperRoute::getArticleRoute($item->slug, $item->catslug));
}
$item->link = JRoute::_('index.php?option=com_users&view=login&return=' . base64_encode($item->link));
}

Thansk for your help and Happy Christmas!

Share this post


Link to post
Share on other sites

I don't see your code different with mine.

You use 2 conditions

if ($access || in_array($item->access, $authorised)) {

and

else if(!$access || !in_array($item->access, $authorised)) {

This equal with no condition as my code. I only need 2nd condition to check if user is not allow access article's link.

Share this post


Link to post
Share on other sites

Hi.

Yes, your code was correct, and my code seems equals to yours.

But with your code, when user logged in, the BT Content Slider shows the links with "return" parameter and Base64 article name.

Clicking the link, the system redirects to the logout page.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now