http://www.icyphoenix.com/viewtopic.php?f=35&t=7717
-----------------------------------
KugeLSichA
Mon 14 Mar, 2011 23:11

Global Language Change Block
-----------------------------------
Hey guys,

i´ve been working on this for 2 days now... and cant figure it out... i hope you can give me some tips...

I want to let my users change there lang in a easy way... so i´ve done this so far, look the picture...
 [img]http://www.icyphoenix.com/files/images/6/lang_select.png[/img] 
Deactivated the lang select function in page_header, an put the function in a block file, and the added the block file as global block via CMS...

Works pretty good! ... [b]BUT:[/b] only for guests...

I want to allow loggedin users this feature too... I tried to take some functions from usercp_register but cant get this to work if the user is logged in... 

Can someone help me the add the needed code lines/sql queries to update the users lang in the DB...

here is my work so far...

[b]blocks\blocks_imp_lang.php[/b]
[spoiler][code linenumbers=false]<?php
/**
*
* @package Icy Phoenix
* @version $Id: blocks_imp_lang.php 49 2008-09-14 20:36:03Z Mighty Gorgon $
* @copyright (c) 2008 Icy Phoenix
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

if (!defined('IN_ICYPHOENIX'))
{
	die('Hacking attempt');
}

if(!function_exists('imp_lang_block_func'))
{
	function imp_lang_block_func()
	{
		global $template, $lang, $board_config, $userdata;
		// Mighty Gorgon - Change Lang/Style - Begin
		if ((($board_config['select_lang'] == true) && (!$userdata['session_logged_in'])))
		{
			include_once(IP_ROOT_PATH . 'includes/functions_selects.' . PHP_EXT);

			if (($board_config['select_lang'] == true) && (!$userdata['session_logged_in']))
			{
				$template->assign_block_vars('lang_select_on', array());
				$lang_installed = language_select_h($board_config['default_lang'], 'language');

				while (list($displayname) = @each($lang_installed))
				{
					$lang_value = $displayname;
					$lang_name = ucwords($displayname);
					$template->assign_block_vars('lang_select_on.lang_select', array(
						'LANG_FLAG' => 'language/lang_' . $displayname . '/flag.png',
						'LANG_NAME' => $lang_name,
						'LANG_VALUE'=> $lang_value,
						'U_LANG_CHANGE'=> append_sid('changelang.' . PHP_EXT . '?' . LANG_URL . '=' . $lang_value),
						)
					);
				}
			}
		}
// Mighty Gorgon - Change Lang/Style - End
	}
}

imp_lang_block_func();

?>[/code][/spoiler]

[b]templates\default\blocks\lang_block.tpl[/b]
[spoiler][code linenumbers=false][/code]<!-- BEGIN lang_select_on -->
<table class="empty-table" width="100%" cellspacing="0" cellpadding="0" border="0">
<!-- BEGIN lang_select -->
<tr>
	<td>
		<br /><a href="{lang_select_on.lang_select.U_LANG_CHANGE}">
		<img src="{lang_select_on.lang_select.LANG_FLAG}" alt="{lang_select_on.lang_select.LANG_NAME}" />
		</a>
	</td>
</tr>
<!-- END lang_select -->
</table>
<!-- END lang_select_on -->[/spoiler]

Thanks in advance!


-----------------------------------
spydie
Mon 14 Mar, 2011 23:37

Re: Global Language Change Block
-----------------------------------
your doing this for .53 or for new version ??

Ups . sorry.

looks like your on .53 cause new version (svn) got no page header. only globals

[hr]

i think you forgot to declare : $lang_select = '';

on the begining of the function

[code linenumbers=false]
        // Mighty Gorgon - Change Lang/Style - Begin
        $lang_select = '';
        if ((($board_config['select_lang'] == true) && (!$userdata['session_logged_in'])))[/code]

hm and maybe include the constants.php because of the defines

this is just a snippet of your code


-----------------------------------
KugeLSichA
Mon 14 Mar, 2011 23:57

Re: Global Language Change Block
-----------------------------------
Hi spydie!

[quote user="spydie" post="51997"]your doing this for .53 or for new version ??

Ups . sorry.

looks like your on .53 cause new version (svn) got no page header. only globals[/quote]

oh yeah i forgot that... sorry...

not a .53 its a beta version from some time ago... but similar to .53 (not the SVN version)

[quote user="spydie" post="51997"]
i think you forgot to declare : $lang_select = '';

on the begining of the function

[code linenumbers=false]
        // Mighty Gorgon - Change Lang/Style - Begin
        $lang_select = '';
        if ((($board_config['select_lang'] == true) && (!$userdata['session_logged_in'])))[/code]

this is just a snippet of your code[/quote]

yupp but this var is for the guests not needed...

and for the logged in users i also tried with this var... -> not working


-----------------------------------
spydie
Tue 15 Mar, 2011 00:02

Re: Global Language Change Block
-----------------------------------
hm

i´ll have a look on that tomorow. bit late allready.

let´s see, if i finish my menu mod first


