News: When asking for support, it helps us and you, if you read the Posting Guidelines

Login  |  Register
HTML5 Icon HTML5 Icon
TP on Social Media
Welcome, Guest. Please login or register.
Did you miss your activation email?

May 25, 2019, 03:08:12 AM

Login with username, password and session length

Recent

Members
  • Total Members: 3751
  • Latest: pyxis
Stats
  • Total Posts: 188251
  • Total Topics: 20707
  • Online Today: 26
  • Online Ever: 629
  • (November 08, 2018, 01:36:54 PM)
Users Online
Users: 0
Guests: 15
Total: 15

Author Topic: Theme switcher always redirects to 'forum'  (Read 208 times)

0 Members and 1 Guest are viewing this topic.

Offline @rjen

  • Support Team
  • *
  • Posts: 1616
    • FJR-club Nederland
Theme switcher always redirects to 'forum'
« on: February 23, 2019, 01:06:04 AM »
Just looking at this report: https://www.simplemachines.org/community/index.php?topic=27642.msg4007889#msg4007889

It seems a bit funny indeed, that changing a theme 'exits' to the forumindex page. Seems more logical that it keeps you on the page you are on... especially if the 'theme switcher' is not showing on all pages...

Digging through the code, we are setting the destination to be 'forum' if this variable is not set: $context['TPortal']['querystring'])
Unfortunately it seems to be never set (?).

I guess this is a question for tino: any way we can always redirect the them switcher to the current page?

It's in this code in TPsubs.template.php:
Code: [Select]
// TPortal themebox
function TPortal_themebox()
{
global $context, $settings, $scripturl, $txt, $smcFunc, $forum_version;

$what = explode(',', $context['TPortal']['themeboxbody']);
$temaid = array();
$temanavn = array();
$temapaths = array();
foreach($what as $wh => $wht)
{
$all = explode('|', $wht);
if($all[0] > -1)
{
$temaid[] = $all[0];
$temanavn[] = isset($all[1]) ? $all[1] : '';
$temapaths[] = isset($all[2]) ? $all[2] : '';
}
}

if(isset($context['TPortal']['querystring']))
$tp_where = $smcFunc['htmlspecialchars'](strip_tags($context['TPortal']['querystring']));
else
$tp_where = 'action=forum';

if($tp_where != '')
$tp_where .= ';';

// remove multiple theme=x in the string.
$tp_where=preg_replace("'theme=[^>]*?;'si", "", $tp_where);

if(is_countable($temaid) && count($temaid) > 0){
        echo '
<form name="jumpurl1" onsubmit="return jumpit()" class="middletext" action="" style="padding: 0; margin: 0; text-align: center;">
<select style="width: 100%; margin: 5px 0px 5px 0px;" size="1" name="jumpurl2" onchange="check(this.value)">';
         for($a=0 ; $a<(count($temaid)); $a++)
{
                echo '
<option value="'.$temaid[$a].'" ', $settings['theme_id'] == $temaid[$a] ? 'selected="selected"' : '' ,'>'.substr($temanavn[$a],0,20).'</option>';
         }
echo '
</select><br>' , $context['user']['is_logged'] ?
'<input type="checkbox" value=";permanent" onclick="realtheme()" /> '. $txt['tp-permanent']. '<br>' : '' , '<br>
<input class="button_submit" type="button" value="'.$txt['tp-changetheme'].'" onclick="jumpit()" /><br><br>
<input type="hidden" value="'.$smcFunc['htmlspecialchars']($scripturl . '?'.$tp_where.'theme='.$settings['theme_id']).'" name="jumpurl3" />
<div style="text-align: center; width: 95%; overflow: hidden;">';


Running TP1.6.3 on SMF2.0 at: www.fjr-club.nl

Testing TP on SMF2.0
Testing TP on SMF2.1 RC2
Want to check what php version I am testing on? See: PHP Info

Offline @rjen

  • Support Team
  • *
  • Posts: 1616
    • FJR-club Nederland
Re: Theme switcher always redirects to 'forum'
« Reply #1 on: February 23, 2019, 01:18:33 AM »
Somehow the querystring is not set in TPortal_init()

Code: [Select]
// TinyPortal init
function TPortal_init()
{
global $context, $txt, $user_info, $settings, $boarddir, $sourcedir, $modSettings, $forum_version;

// has init been run before? if so return!
if(isset($context['TPortal']['redirectforum']))
return;

if(loadLanguage('TPortal') == false)
loadLanguage('TPortal', 'english');

$context['TPortal'] = array();
$context['TPortal']['querystring'] = $_SERVER['QUERY_STRING'];

 :hmm:
Running TP1.6.3 on SMF2.0 at: www.fjr-club.nl

Testing TP on SMF2.0
Testing TP on SMF2.1 RC2
Want to check what php version I am testing on? See: PHP Info

Offline tino

  • Developer
  • *
  • Posts: 1563
Re: Theme switcher always redirects to 'forum'
« Reply #2 on: February 23, 2019, 01:32:51 AM »
I’ll look into it later. Inkling would be the server string is empty or similar when assigning.

Offline @rjen

  • Support Team
  • *
  • Posts: 1616
    • FJR-club Nederland
Re: Theme switcher always redirects to 'forum'
« Reply #3 on: February 23, 2019, 01:57:46 AM »
Thats my guess too. I read somewhere that this is dependent on server setup, and that a GET command may be needed...
Running TP1.6.3 on SMF2.0 at: www.fjr-club.nl

Testing TP on SMF2.0
Testing TP on SMF2.1 RC2
Want to check what php version I am testing on? See: PHP Info

Offline lurkalot

  • Administrator
  • *
  • Posts: 5991
    • Camera Craniums
Re: Theme switcher always redirects to 'forum'
« Reply #4 on: February 23, 2019, 02:00:01 AM »

Seems more logical that it keeps you on the page you are on...


Good call, this is slightly annoying now it's been brought to attention. Can't confirm if this happened with older versions such as TP1.0

There was I'm sure something else that took you to a different page after hitting submit, but can't for the life of me remember what it was, perhaps while I was messing around with the downloads sys the other day.  I'll have to see if I can find it, I know at the time it made me think, WTF. lol..

Offline tino

  • Developer
  • *
  • Posts: 1563
Re: Theme switcher always redirects to 'forum'
« Reply #5 on: February 23, 2019, 05:01:14 AM »
Just commited the fix for this into the master branch.

Offline @rjen

  • Support Team
  • *
  • Posts: 1616
    • FJR-club Nederland
Re: Theme switcher always redirects to 'forum'
« Reply #6 on: February 23, 2019, 05:30:45 AM »
Did setupTPsettings wipe the setting? I did not see that. What statement caused that?
Running TP1.6.3 on SMF2.0 at: www.fjr-club.nl

Testing TP on SMF2.0
Testing TP on SMF2.1 RC2
Want to check what php version I am testing on? See: PHP Info

Offline tino

  • Developer
  • *
  • Posts: 1563
Re: Theme switcher always redirects to 'forum'
« Reply #7 on: February 23, 2019, 05:44:35 AM »
Did setupTPsettings wipe the setting? I did not see that. What statement caused that?

That line..

Code: [Select]
if (($context['TPortal'] = cache_get_data('tpSettings', 90)) == null)