Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2007-12-08 06:18:27

net-carver
Archived Plugin Author
Registered: 2006-03-08
Posts: 1,648

Re: Switch language menu for all users

François

Try this at the beginning of your function that needs to call languages()

global $txpcfg;
include_once( $txpcfg['txpath'].DS.'include'.DS.'txp_prefs.php' );

Steve

Offline

#14 2007-12-08 06:31:34

fpradignac
Plugin Author
From: France near Cognac
Registered: 2005-01-29
Posts: 359
Website

Re: Switch language menu for all users

Early in the morning Steve ;-)
Thanks for this : I’ll have a try after breakfast !
Quickly : if I understood your snippet, the thing is to load the file itself before call the function.


françois

Offline

#15 2007-12-08 06:35:06

net-carver
Archived Plugin Author
Registered: 2006-03-08
Posts: 1,648

Re: Switch language menu for all users

Yes, from your earlier post about the error message it sounds like you’ll need to load the file before you can call the function.


Steve

Offline

#16 2007-12-10 06:06:33

fpradignac
Plugin Author
From: France near Cognac
Registered: 2005-01-29
Posts: 359
Website

Re: Switch language menu for all users

OK : my beta version is working… but :
  • using register_callback("plug", "admin","",0); put my snippet after the rest of the page code, so when I save the selected language, there’s only the footer of the page that change with the new language immediately (but when I look at an other tab : all is OK).
  • The best way is to put the snippet at the top of the page just after the body tag, but register_callback("plug", "admin","",1); put it out of the html code.
  • is there’s a way to put my snippet just after the body tag, before the rest of the txp page code will be loaded ?
  • is the “rewrite on the fly” of the buffer is the only solution ?

françois

Offline

#17 2007-12-10 07:37:40

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: Switch language menu for all users

register_callback("plug", "admin","",0); and use Javascript to insert the HTML in the right spot.

Offline

#18 2007-12-10 07:57:21

fpradignac
Plugin Author
From: France near Cognac
Registered: 2005-01-29
Posts: 359
Website

Re: Switch language menu for all users

ruud a écrit:

register_callback("plug", "admin","",0); and use Javascript to insert the HTML in the right spot.

Thanks ruud : will have a look at this Javascript way.


françois

Offline

#19 2007-12-12 08:02:09

fpradignac
Plugin Author
From: France near Cognac
Registered: 2005-01-29
Posts: 359
Website

Re: Switch language menu for all users

Well I’ve used Javascript with DOM to put my dropdown menu on the right place of the DOM : it’s OK.
… but I have the same issue : when the code is loaded by PHP, “my” snippet is executed after the rest of the page (register_callback("plug", "admin","",0)), so when I save the selected language, there’s only the footer of the page that changed immediately with the new language.

I think that I should take the buffer on the fly and work on it : but at now, I can’t figure out how to capture it : I saw developpers using
function myfunc($buffer) ....
but I don’t understand where $buffer come from : any idea are welcome ;-)

Last edited by fpradignac (2007-12-12 08:13:25)


françois

Offline

#20 2007-12-12 08:08:30

net-carver
Archived Plugin Author
Registered: 2006-03-08
Posts: 1,648

Re: Switch language menu for all users

françois

Check out ob_start() at php.net.

Have to run now, will check back later.


Steve

Offline

#21 2007-12-12 08:21:49

fpradignac
Plugin Author
From: France near Cognac
Registered: 2005-01-29
Posts: 359
Website

Re: Switch language menu for all users

Thanks Steve, I saw and try ob_start() but for now, it’s a bite “esotheric” for me … but I will take more time to understand this PHP buffering output function : it’s the good way for me.


françois

Offline

#22 2007-12-12 09:30:58

fpradignac
Plugin Author
From: France near Cognac
Registered: 2005-01-29
Posts: 359
Website

Re: Switch language menu for all users

OK ! I’ve got it now, just a little improvment and it will be good for me.


françois

Offline

#23 2007-12-12 10:12:21

net-carver
Archived Plugin Author
Registered: 2006-03-08
Posts: 1,648

Re: Switch language menu for all users

françois

back again — but sounds like you worked out the missing connection between your function myfunc($buffer) and the ob_start( 'myfunc' ); for yourself. <grin>


Steve

Offline

#24 2007-12-12 15:33:23

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: Switch language menu for all users

The language choice can be done like that (0 as last parameter in register_callback), but once the language is chosen, you use a callback to change the language before the page begins rendering (1 as last parameter). So you need 2 register_callbacks.

Offline

Board footer

Powered by FluxBB