TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

July 20, 2024, 04:45:18 PM

Login with username, password and session length
Members
Stats
  • Total Posts: 195,333
  • Total Topics: 21,233
  • Online today: 133
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 69
  • Total: 69

Theme switcher always redirects to 'forum'

Started by @rjen, February 23, 2019, 08:06:04 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

@rjen

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:

// 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 Latest TP on SMF2.1 at: www.fjr-club.nl

@rjen

Somehow the querystring is not set in TPortal_init()


// 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 Latest TP on SMF2.1 at: www.fjr-club.nl

tino

I'll look into it later. Inkling would be the server string is empty or similar when assigning.

@rjen

Thats my guess too. I read somewhere that this is dependent on server setup, and that a GET command may be needed...
Running Latest TP on SMF2.1 at: www.fjr-club.nl

lurkalot

Quote from: @rjen on February 23, 2019, 08:06:04 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..

tino

Just commited the fix for this into the master branch.

@rjen

Did setupTPsettings wipe the setting? I did not see that. What statement caused that?
Running Latest TP on SMF2.1 at: www.fjr-club.nl

tino

Quote from: @rjen on February 23, 2019, 12:30:45 PM
Did setupTPsettings wipe the setting? I did not see that. What statement caused that?

That line..

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