Page 1 of 5

multiple languages and redirection

Posted: Sun 22. Aug 2004, 00:07
by Oliver Georgi
If you use multiple languages in phpwcms like this:

HOME
- de
- en
- fr

and you want to use language based redirection fill in these lines of code in header section of default template

Code: Select all

[PHP]
if(!$GLOBALS['aktion'][0]) {

	switch( strtolower( substr( $_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2 ) ) ) {
		case 'de':	header('Location: '.$GLOBALS['phpwcms']['site'].$GLOBALS['phpwcms']['root'].'index.php?de');
					exit();
					break;
		default:	header('Location: '.$GLOBALS['phpwcms']['site'].$GLOBALS['phpwcms']['root'].'index.php?en');
					exit();		
	}

}
[/PHP]
Enhance the other languages like "case 'de':"

Oliver

Posted: Thu 26. Aug 2004, 17:40
by StudioZ
Awesome Oliver !

Thanks :wink:

Need a mechanic to check this for me ;-)

Posted: Wed 15. Sep 2004, 20:03
by StudioZ
Oh... :?

Need some precisions on this interesting script... :wink:

I modified Oliver's Script (above), to work for my site,
and I placed it in the "header:" field of my default (french) template.

Code: Select all

[PHP]
if(!$GLOBALS['aktion'][0]) {

   switch( strtolower( substr( $_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2 ) ) ) {
      case 'en':   header('Location: '.$GLOBALS['phpwcms']['site'].$GLOBALS['phpwcms']['root'].'index.php?welcome');
               exit();
               break;
      default:   header('Location: '.$GLOBALS['phpwcms']['site'].$GLOBALS['phpwcms']['root'].'index.php?accueil');
               exit();      
   }

}
[/PHP]
Question 01:
Is it working for you folks... :?:

Question 02:
Did I placed it in the wright section of the template... :?:

Thank you again for your time,

Posted: Wed 15. Sep 2004, 20:49
by Pappnase
hello

i place the script into the summary of the first article into the root

exp.

root
article
-first lag folder
-second lang folder

Posted: Wed 15. Sep 2004, 21:03
by StudioZ
Pappnase wrote:hello

i place the script into the summary of the first article into the root

exp.

root
article
-first lag folder
-second lang folder
hmmmm... I'll check this also ;-)
Much appreciated Pappnase :D

Take care!

It works now ;-)

Posted: Wed 15. Sep 2004, 21:15
by StudioZ
Hey Pappnase !!!!
Thanks a bunch for this help!
Awesome ! Simply awesome :wink:

EDIT:
and.. Thank you Oliver for this script and... most of all... this CMS !!!!

Take care :wink:

Re: It works now ;-)

Posted: Wed 15. Sep 2004, 21:25
by Pappnase
StudioZ wrote:Hey Pappnase !!!!
Thanks a bunch for this help!
Awesome ! Simply awesome :wink:

EDIT:
and.. Thank you Oliver for this script and... most of all... this CMS !!!!

Take care :wink:
hello

i need to be true! there was also a little help from oliver!*g

Language Redirection Script [vs] Search

Posted: Fri 17. Sep 2004, 04:43
by StudioZ
Greetings,

As a follow-up on this... I realized that when I use the Language Redirection Script (BTW which works very well) well... then when you use the Search on my site for an expression like (ex.: " logo"), the results shows Index as being the first result and an error message for this result only.

Not sure I will keep the Search Option open for long, but... take a chance:
http://www.malouin.ws/design/fr_recherche.phtml

Here's the error message you will get:
Parse error: parse error, unexpected '}' in /home/user/public_html/design/include/inc_front/front.func.inc.php(2048) : eval()'d code on line 1

And here's the code I have in my root index page's WYSYWIG summary' part:

Code: Select all

[PHP] if(!$GLOBALS['aktion'][0]) { switch( strtolower( substr( $_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2 ) ) ) { case 'en': header('Location: '.$GLOBALS['phpwcms']['site'].$GLOBALS['phpwcms']['root'].'index.php?welcome'); exit(); break; default: header('Location: '.$GLOBALS['phpwcms']['site'].$GLOBALS['phpwcms']['root'].'index.php?accueil'); exit(); } } [/PHP]
and here's the piece of code to which the error is referring in
include/inc_front/front.func.inc.php(2048):

Code: Select all

function include_int_phpcode($string) {
	// return the PHP code
	$s = html_despecialchars($string[1]);
	$s = str_replace('<br>', "\n", $s);
	$s = str_replace('<br />', "\n", $s);
	ob_start();
	eval($s.";"); //       <----------------------- THIS IS LINE 2048 !
	$return = ob_get_contents();
	ob_end_clean();
	return $return;
}
Any insight on how to patch this...? :roll:
Can anyone reproduce this behavior on their sites? :?

Kind Regards,

Posted: Fri 17. Sep 2004, 06:33
by Oliver Georgi
search is not very optimal at the moment - too slow and too many problems because of such error you have seen. Sorry.

Try to put the peace of code into an external file and use {PHP:.....}

Oliver

Posted: Fri 17. Sep 2004, 06:48
by StudioZ
Oliver Georgi wrote:search is not very optimal at the moment - too slow and too many problems because of such error you have seen. Sorry.

Try to put the peace of code into an external file and use {PHP:.....}

Oliver
Thank you Oliver for your help and input 8)
I'll try that in the next few hours, after a good night sleep :wink:

Kind Regards,

Confirmation: Your solution works! Thanks!

Posted: Fri 17. Sep 2004, 18:29
by StudioZ
Thank you Oliver :)
Your suggestion is working !!!!
I applied it to my site.

This solution proves again how much your "Coding Œuvre" is flexible 8)

Take care and thanks again! :wink:

Posted: Tue 21. Sep 2004, 16:49
by cmsler
hmm...ich bin wohl definitiv zu blöd...

...in welche Datei und wohin genau muss diese language-redirection kopiert werden?

besten Dank für baldige Hilfe
cmsler

Posted: Tue 21. Sep 2004, 20:29
by Pappnase
hallo

in den ersten artikle im root*smile*

Posted: Wed 22. Sep 2004, 08:08
by cmsler
hi...das war ja super einfach :lol:

besten Dank, cmsler

Posted: Fri 24. Sep 2004, 10:53
by cmsler
...wäre auch noch eine Zeitverzögerung von z.B. 5 Sekunden möglich, um die Seite trotzdem kurz anzuzeigen (z.B. für individuelle Error 404 Seite, oder die dbdown.php)?

Gruss cmsler