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.
You'll have to take the code an edit it from the TPBlocks file.
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 .=';';
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. :)
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'];
}
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.
Should be able to remove this part:
for($a=0 ; $a<(sizeof($temaid)) ; $a++){
echo '
themepath['.$temaid[$a].'] = "'.$temapaths[$a].'/thumbnail.gif"
';
}
If I try to use it i get this error: unexpected T_STRING