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

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,966
  • Latest: safir45
Stats
  • Total Posts: 195,994
  • Total Topics: 21,325
  • Online today: 777
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 1
  • Guests: 82
  • Total: 83
  • @rjen

Theme changer

Started by calumks, March 18, 2009, 08:25:02 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

calumks

I would like to add the theme changer block without the theme thumbnail in a theme's index.template.php Is there some colde I could paste into the template.

IchBin

You'll have to take the code an edit it from the TPBlocks file.

calumks

Can somone edit it for me the code is:

// TPortal themebox

function TPortal_themebox()
{
global $context, $settings, $options, $scripturl, $txt, $modSettings, $user_info;

$temaid=explode(',',$context['TPortal']['temaer']);
$temanavn=explode(',',$context['TPortal']['temanames']);
$temapaths=explode(',',$context['TPortal']['temapaths']);
if(isset($context['TPortal']['querystring']))
$tp_where=htmlspecialchars(strip_tags($context['TPortal']['querystring']));
else
$tp_where='action=forum;';

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

IchBin

That is only a small portion of the code. Notice the "{" below the word function? There has to be a closing "}" character that lines up with the opening character. Once you find that character you know you've found the end of the code. :)

calumks

here we go:
// TPortal themebox
function TPortal_themebox()
{
global $context, $settings, $options, $scripturl, $txt, $modSettings, $user_info;

$temaid=explode(',',$context['TPortal']['temaer']);
$temanavn=explode(',',$context['TPortal']['temanames']);
$temapaths=explode(',',$context['TPortal']['temapaths']);
if(isset($context['TPortal']['querystring']))
$tp_where=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(sizeof($temaid)>1){
        echo '
<form name="jumpurl1" onsubmit="return jumpit()" 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<(sizeof($temaid)) ; $a++){
                echo '
<option value="'.$temaid[$a].'" ', $settings['theme_id'] == $temaid[$a] ? 'selected="selected"' : '' ,'>'.substr($temanavn[$a],0,20).'</option>';
         }
         echo '
</select><br />
<input type="checkbox" value=";permanent" onfocus="realtheme()" /> ', $txt['tp-permanent'], '<br />
<input style="margin: 5px 0px 5px 10px;" type="button" value="'.$txt['tp-changetheme'].'" onclick="jumpit()" />
<input type="hidden" value="'.htmlspecialchars($scripturl . '?'.$tp_where.'theme='.$settings['theme_id']).'" name="jumpurl3" />
<div style="text-align: center; width: 95%; overflow: hidden;">
<img src="'.$settings['images_url'].'/thumbnail.gif" alt="" id="chosen" name="chosen"  />
</div>
</form>
<script type="text/javascript" language="Javascript">
var extra = \'\';
var themepath=new Array()';
         for($a=0 ; $a<(sizeof($temaid)) ; $a++){
echo '
    themepath['.$temaid[$a].'] = "'.$temapaths[$a].'/thumbnail.gif"
';
}

echo '
function jumpit(){
                          window.location=document.jumpurl1.jumpurl3.value + extra
                          return false
                       }
                   </script>
   <script type="text/javascript">
       function realtheme()
       {
extra = \';permanent\';
       }
        function check(icon)
       {
document.chosen.src= themepath[icon]
document.jumpurl1.jumpurl3.value = \'' . $scripturl . '?'. $tp_where.'theme=\' + icon
       }
</script>';
}
else
echo $txt['tp-nothemeschosen'];
}



Ken.

Quote from: calumks on March 19, 2009, 10:43:39 PM
.





Was there some missing commentary in your post, or is it just a bump?
If it's a bump then you should know that's not really necessary because someone will look at your code soon enough. 
" If everything seems under control, you're not going fast enough." - Mario Andretti
Yesterday When I was Young.

IchBin

Should be able to remove this part:
         for($a=0 ; $a<(sizeof($temaid)) ; $a++){
echo '
    themepath['.$temaid[$a].'] = "'.$temapaths[$a].'/thumbnail.gif"
';
}

calumks

If I try to use it i get this error: unexpected T_STRING

This website is proudly hosted on Crocweb Cloud Website Hosting.