News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Botão de Mudar Theme

Started by TaijovuNeji, July 15, 2009, 10:57:17 PM

Previous topic - Next topic

TaijovuNeji

Eu to tentando criar um botão que mude para um theme leve e outro que mude para o theme padrão.. mas não to conseguindo O.o...

Como que eu faço isso? Eu coloco o link do theme mas como a id do membro que vai clicar é diferente da minha.. dae não vai.. mas quando eu tento verificar a id do membro não acontece nada O.O.. eu criei esse código pra fazer isso:

//Botões de trocar Theme
echo '
        <div align="right">
    <table width="22%" border="0">
    <tr>
      <td><a href="', $scripturl, '?action=theme;sa=pick;u=', $context['member']['id'], ';sesc=', $context['session_id'], '">Theme
        Light</a> </td>
    </tr>
    </table>
    </div>';


Alguém consegue me ajudar a arrumar isso? XD
Hospedagem 20GB, Cpanel, Windows ou Linux, com suporte a PHP ou ASP, R$ 30,00 por mes ou 290 por ano


meu site: http://www.dungeonmakers.com.br/forum
Não atendo PM para pedidos de suporte/ajuda. Para isso existe o forum!!!

margarett

Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

TaijovuNeji

Opa gostei do mod XD.. mas cara eu queria fazer diferente.. eu queria colocar duas imagens abaixo do banner... uma que ao clicar levasse eu theme light e outra que levasse ao theme padrão XD..
Será que tem como fazer isso? Oo.. eu procurei em várias páginas php do servidor e não achei o código de mudança de theme O.O
Hospedagem 20GB, Cpanel, Windows ou Linux, com suporte a PHP ou ASP, R$ 30,00 por mes ou 290 por ano


meu site: http://www.dungeonmakers.com.br/forum
Não atendo PM para pedidos de suporte/ajuda. Para isso existe o forum!!!

Apllicmz

Talvez pensar em frames..
se o php nao serve



margarett

Estás no 2.0 ou no 1.1.x?

No 2.0 não sei, mas no 1.1, basta-te fazer
www.forum.com/index.php?theme=1
www.forum.com/index.php?theme=2
...
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

TaijovuNeji

#5
Eu to usando o 1.1.10
Mas é soh fazer isso que tu falou? Oo.. eu achei que tinha que colocar verificação de ID do membro O.o
Eu vou tentar fazer isso XD..  depois eu falo se funcionou ^^

::: Edit :::

Cara eu fiz o que tu falou e apareceu que a página na foi encontrada  :'(

mesmo assim vlw pela ajuda ^^
Hospedagem 20GB, Cpanel, Windows ou Linux, com suporte a PHP ou ASP, R$ 30,00 por mes ou 290 por ano


meu site: http://www.dungeonmakers.com.br/forum
Não atendo PM para pedidos de suporte/ajuda. Para isso existe o forum!!!

Apllicmz

#6
Alguma coisa fez mal..
porque funciona como ve aqui nestes demos

http://editado.net/




Costa

Link editado, enquanto não for resolvido o problema que em relação aos direitos de copyright os links daí serão censurados, ok?
Queres divulgar o teu site, mete-o no google, se quiseres ajudar o pessoal do SMF, postas aqui a solução em forma de tópico, ou post
Já não é a primeira vez que o fazes


- [ Costa ]
Simple Machines Forum Team
Hugo "Costa" Fernandes - PT SMF
Todas as MP's a pedir ajuda são sujeitas a radioactividade, microondas, queimadas e atiradas borda fora.

"At least someone appreciates the fact that I am doing and not thinking..."
"Laziness is counter-revolutionary."

TaijovuNeji

O.o ele soh quis me dar um exemplo do que tava falando O.O
Se tu não tivesse arrancado o link talvez eu até tivesse resolvido meu problema XD

@joomlamz : me manda o link por pm.. e eu não fiz nada errado.. eu fiz isso: www.dungeonmakers.com.br/forum/index.php?theme=1

E não muda de theme Oo.. eu tentei colocar do número 1 até o 11 e soh mostra que a página não foi encontrada..
Hospedagem 20GB, Cpanel, Windows ou Linux, com suporte a PHP ou ASP, R$ 30,00 por mes ou 290 por ano


meu site: http://www.dungeonmakers.com.br/forum
Não atendo PM para pedidos de suporte/ajuda. Para isso existe o forum!!!

Costa

Off

Taijovu, estou a cumprir ordens cara
Sorry, mas é o que os chefes do SMF mandam a gente fazer

O suporte é aqui no SMF, se ele quisesse emsmo ajudar tinha metido uma imagem ou escrito aqui como fazer

Abraço
Hugo "Costa" Fernandes - PT SMF
Todas as MP's a pedir ajuda são sujeitas a radioactividade, microondas, queimadas e atiradas borda fora.

"At least someone appreciates the fact that I am doing and not thinking..."
"Laziness is counter-revolutionary."

TaijovuNeji

Foi mal cara.. eu sei como é XD.. eu sou dono de uma comunidade e moderador de outro ^^... mas tu lembra o link que ele postou? Se puder me manda por mensagem pessoal.. eu preciso muito resolver isso ^.^
Hospedagem 20GB, Cpanel, Windows ou Linux, com suporte a PHP ou ASP, R$ 30,00 por mes ou 290 por ano


meu site: http://www.dungeonmakers.com.br/forum
Não atendo PM para pedidos de suporte/ajuda. Para isso existe o forum!!!

Costa

consegues amanhar-te com a função em php?  :)

//Settings Start here, they are all checked, and disable itself it it not usefull to disable it ;P

//This will show the Submit button, this is only for user who disable the Javascript, if you don't like it you can remove it by set it to 0
$showSubmitButton = 1;
//Auto Remove the button if Java Script avaible and enabled and the button is shown
$autoRemoveButton = 1;
//Disable the Java Script? 0 = No, 1 = Yes!
$autoSubmitThemeChange = 0;
//Enable the Images? Disable the autoSubmitThemeChange for this! Only one of them will work ;)
$showPreviewImages = 1;
//Change Theme Text for the Button
$txt['sp_ThemeChange_submit'] = 'Mudar de Skin';

//Here start the script :D and you know if you not know what you do do nothing after this ;)
global $modSettings, $context, $db_prefix, $settings, $txt, $ID_MEMBER, $scripturl, $user_info;

//Checkup Settings :) Fix them so that it work ;)
$autoSubmitThemeChange = !empty($autoSubmitThemeChange);
$showPreviewImages = !empty($showPreviewImages);
$showSubmitButton = $showPreviewImages || !empty($showSubmitButton) || !$autoSubmitThemeChange;
$autoRemoveButton = $showSubmitButton && $autoSubmitThemeChange && !empty($autoRemoveButton);
$txt['sp_ThemeChange_submit'] = empty($txt['sp_ThemeChange_submit']) ? 'Mudar de Skin' : $txt['sp_ThemeChange_submit'];

//Load the Themerelated Language Things :)
loadLanguage('Profile');

// Load the themes for pull down list
$request = db_query("
SELECT ID_THEME, variable, value
FROM {$db_prefix}themes
WHERE variable IN ('name', 'theme_dir', 'theme_url', 'images_url')
AND ID_MEMBER = 0", __FILE__, __LINE__);

while ($row = mysql_fetch_assoc($request))
{
if (!isset($context['themes'][$row['ID_THEME']]))
$context['themes'][$row['ID_THEME']] = array(
'id' => $row['ID_THEME'],
);
$context['themes'][$row['ID_THEME']][$row['variable']] = $row['value'];
}
mysql_free_result($request);

//Let's see if i should update the theme on the userdata?
if(isset($_REQUEST['th']) && is_numeric($_REQUEST['th'])) {
checkSession('get');
$_REQUEST['th'] = (int) $_REQUEST['th'];
//Fall back to default?
if(empty($context['themes'][$_REQUEST['th']]))
$_REQUEST['th'] = -1;
if(!$context['user']['is_guest'])
updateMemberData($ID_MEMBER, array('ID_THEME' => ($_REQUEST['th'] == -1 ? 0 : $_REQUEST['th'])));
redirectexit('theme='.$_REQUEST['th']);
}

//Load the current user theme, could be possible updated ;)
if(!$context['user']['is_guest']) {
$request = db_query("
SELECT ID_THEME
FROM {$db_prefix}members
WHERE ID_MEMBER = $ID_MEMBER
LIMIT 1", __FILE__, __LINE__);
list ($context['current_theme']) = mysql_fetch_row($request);
mysql_free_result($request);
}
else
$context['current_theme'] = 0; //Only for guest ;)

//Enable the Image Thumbnails?
$context['current_theme_thumb'] = '';
if($showPreviewImages) {
foreach ($context['themes'] as $ID_THEME => $theme_data)
{
// Don't try to load the forum or board default theme's data... it doesn't have any!
if ($ID_THEME == 0)
continue;

$settings = $theme_data;
$settings['theme_id'] = $ID_THEME;

if (file_exists($settings['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php'))
include($settings['theme_dir'] . '/languages/Settings.' . $user_info['language'] . '.php');
elseif (file_exists($settings['theme_dir'] . '/languages/Settings.' . $language . '.php'))
include($settings['theme_dir'] . '/languages/Settings.' . $language . '.php');
else
{
$txt['theme_thumbnail_href'] = $settings['images_url'] . '/thumbnail.gif';
$txt['theme_description'] = '';
}

$context['themes'][$ID_THEME]['thumbnail_href'] = $txt['theme_thumbnail_href'];
$context['themes'][$ID_THEME]['description'] = $txt['theme_description'];
}

//Default Theme need an thumnail :D (Hope this work :X)
$context['themes'][0]['thumbnail_href'] = !empty($context['themes'][$modSettings['theme_default']]['thumbnail_href']) ? $context['themes'][$modSettings['theme_default']]['thumbnail_href'] : $context['themes'][1]['thumbnail_href'];
//Standardthumb :x
$context['current_theme_thumb'] = $context['themes'][0]['thumbnail_href'];
}

//Default Theme :)
$context['themes'][0]['id'] = 0;
$context['themes'][0]['name'] = $txt['theme_forum_default'];
$context['themes'][0]['description'] = $txt['theme_global_description'];

//Sort it ;)
ksort($context['themes']);

//The Java Script Parts :) Only this or the other not both :O
if($autoSubmitThemeChange)
{
echo '
<script language="JavaScript" type="text/javascript">
function sportal_theme_change(obj)
{
var id = obj.options[obj.selectedIndex].value;
var url = new String(window.location);
loc = \'index.php?th=\' + id + \';sesc=', $context['session_id'], '\';
window.location = loc;
}
</script>';
}
elseif($showPreviewImages)
{
echo '
<script language="JavaScript" type="text/javascript">
var sp_smf_thumb_link_array = new Array();';
foreach($context['themes'] as $key => $item)
echo '
sp_smf_thumb_link_array['.$key.'] = "' . $item['thumbnail_href'] . '";';
echo '
function sportal_theme_change(obj)
{
var id = obj.options[obj.selectedIndex].value;
document.getElementById("sp_theme_thumbnail").src = sp_smf_thumb_link_array[id];
}
</script>';
}


//And the pulldown
echo '
<form>
<div style="text-align: center; width:99%;">
<select name="th"' . ($autoSubmitThemeChange || $showPreviewImages ? ' onchange="sportal_theme_change(this)"' : '') . ' style="width:95%;">';
foreach ($context['themes'] as $theme)
{
if($showPreviewImages && $context['current_theme'] == $theme['id'])
$context['current_theme_thumb'] = $theme['thumbnail_href'];
echo '
<option value="', $theme['id'], '"', ($context['current_theme'] == $theme['id'] ? ' selected="selected"' : ''), '>', $theme['name'], '</option>';
}
echo '
</select>' . ($showPreviewImages ? '
<img style="padding:5px 5px 5px 5px" id="sp_theme_thumbnail" src="'.$context['current_theme_thumb'].'" />' : '') . ($showSubmitButton ? '
<input type="hidden" name="sesc" value="' . $context['session_id'] . '" />
<input style="display:inline;" id="sp_theme_changer_submitt_button" type="submit" value="' . $txt['sp_ThemeChange_submit'] . '" name="submit" />
' : '') . '
</div>
</form>';

//Autoremove the Button?
if($autoRemoveButton)
{
echo '
<script language="JavaScript" type="text/javascript">
document.getElementById("sp_theme_changer_submitt_button").style.display = "none";
</script>';



Hugo "Costa" Fernandes - PT SMF
Todas as MP's a pedir ajuda são sujeitas a radioactividade, microondas, queimadas e atiradas borda fora.

"At least someone appreciates the fact that I am doing and not thinking..."
"Laziness is counter-revolutionary."

TaijovuNeji

Conseguir eu consigo XD.. e vlw ae por postar isso ^^... mas não era isso que eu queria..

Eu queira por um link em uma imagem que mudasse o theme do forum .. e nisso que tu passou é mudado através de botão Oo..

Mas vlw mesmo assim ^.^
Hospedagem 20GB, Cpanel, Windows ou Linux, com suporte a PHP ou ASP, R$ 30,00 por mes ou 290 por ano


meu site: http://www.dungeonmakers.com.br/forum
Não atendo PM para pedidos de suporte/ajuda. Para isso existe o forum!!!

margarett

Deves ter-te enganado em alguma coisa...

Vê neste fórum:
http://www.simplemachines.org/community/index.php?theme=2
http://www.simplemachines.org/community/index.php?theme=1

Por exemplo.
Ora vê lá se o tema não muda,,, Por isso tem de resultar no teu. A informação fica no "cookie", é tão válida quanto alterar o tema no perfil!
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

TaijovuNeji

O.o.. realmente cara eu fiz algo errado .. eu tentei fazer agora novamente do jeito que tu falou e foi O.O

vlw mesmo pela ajuda de todos ^^
Hospedagem 20GB, Cpanel, Windows ou Linux, com suporte a PHP ou ASP, R$ 30,00 por mes ou 290 por ano


meu site: http://www.dungeonmakers.com.br/forum
Não atendo PM para pedidos de suporte/ajuda. Para isso existe o forum!!!

Costa

Hugo "Costa" Fernandes - PT SMF
Todas as MP's a pedir ajuda são sujeitas a radioactividade, microondas, queimadas e atiradas borda fora.

"At least someone appreciates the fact that I am doing and not thinking..."
"Laziness is counter-revolutionary."

Advertisement: