multiple languages and redirection

Get help with installation and running phpwcms here. Please do not post bug reports or feature requests here.
User avatar
Oliver Georgi
Site Admin
Posts: 9892
Joined: Fri 3. Oct 2003, 22:22
Contact:

multiple languages and redirection

Post 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
Last edited by Oliver Georgi on Sun 20. Aug 2006, 11:03, edited 1 time in total.
Oliver Georgi | phpwcms Developer | GitHub | LinkedIn | Систрон
User avatar
StudioZ
Posts: 802
Joined: Fri 28. May 2004, 19:57
Location: Québec, Canada
Contact:

Post by StudioZ »

Awesome Oliver !

Thanks :wink:
Image
PhpWCMS Evangelist, -- iRoutier.com Running phpWCMS 1.4.2, r354 -> Great Version!!!!
User avatar
StudioZ
Posts: 802
Joined: Fri 28. May 2004, 19:57
Location: Québec, Canada
Contact:

Need a mechanic to check this for me ;-)

Post 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,
Image
PhpWCMS Evangelist, -- iRoutier.com Running phpWCMS 1.4.2, r354 -> Great Version!!!!
Pappnase

Post 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
User avatar
StudioZ
Posts: 802
Joined: Fri 28. May 2004, 19:57
Location: Québec, Canada
Contact:

Post 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!
Image
PhpWCMS Evangelist, -- iRoutier.com Running phpWCMS 1.4.2, r354 -> Great Version!!!!
User avatar
StudioZ
Posts: 802
Joined: Fri 28. May 2004, 19:57
Location: Québec, Canada
Contact:

It works now ;-)

Post 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:
Image
PhpWCMS Evangelist, -- iRoutier.com Running phpWCMS 1.4.2, r354 -> Great Version!!!!
Pappnase

Re: It works now ;-)

Post 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
User avatar
StudioZ
Posts: 802
Joined: Fri 28. May 2004, 19:57
Location: Québec, Canada
Contact:

Language Redirection Script [vs] Search

Post 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,
Image
PhpWCMS Evangelist, -- iRoutier.com Running phpWCMS 1.4.2, r354 -> Great Version!!!!
User avatar
Oliver Georgi
Site Admin
Posts: 9892
Joined: Fri 3. Oct 2003, 22:22
Contact:

Post 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
Oliver Georgi | phpwcms Developer | GitHub | LinkedIn | Систрон
User avatar
StudioZ
Posts: 802
Joined: Fri 28. May 2004, 19:57
Location: Québec, Canada
Contact:

Post 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,
Image
PhpWCMS Evangelist, -- iRoutier.com Running phpWCMS 1.4.2, r354 -> Great Version!!!!
User avatar
StudioZ
Posts: 802
Joined: Fri 28. May 2004, 19:57
Location: Québec, Canada
Contact:

Confirmation: Your solution works! Thanks!

Post 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:
Image
PhpWCMS Evangelist, -- iRoutier.com Running phpWCMS 1.4.2, r354 -> Great Version!!!!
cmsler
Posts: 22
Joined: Mon 5. Jul 2004, 17:32

Post 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
Pappnase

Post by Pappnase »

hallo

in den ersten artikle im root*smile*
cmsler
Posts: 22
Joined: Mon 5. Jul 2004, 17:32

Post by cmsler »

hi...das war ja super einfach :lol:

besten Dank, cmsler
cmsler
Posts: 22
Joined: Mon 5. Jul 2004, 17:32

Post 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
Post Reply