Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#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
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
Re: Switch language menu for all users
- 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
Re: Switch language menu for all users
register_callback("plug", "admin","",0);
and use Javascript to insert the HTML in the right spot.
Offline
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
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
— Steve
Offline
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
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
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