config variable in textstring

Third Party Plugins to CMSimple - how to install, use and create plugins

Moderator: Tata

Post Reply
Tata
Posts: 3587
Joined: Tue May 20, 2008 5:34 am
Location: Slovakia
Contact:

config variable in textstring

Post by Tata » Mon May 04, 2020 10:22 pm

In vielen Sprachdateien befindet sich "%s", das dann mit anderswo definirten Varibalen ersetzt ist. Wo finde ich eine Anleitung, wie man eine Variable aus der z.B. Plugin Konfiguration in eine Sprachdatei zu geben?
Z.B:

Code: Select all

$plugin_cf['config_key']['config_value'] = "abcd";

Code: Select all

$plugin_tx['text_key']['text_string'] = "Lorem ipsum %s.";
Auf der Seite dann "Lorem ipsum abcd".
CMSimple.sk
It's no shame to ask for an answer if all efforts failed.
But it's awful to ask without any effort to find the answer yourself.

Holger
Site Admin
Posts: 3470
Joined: Mon May 19, 2008 7:10 pm
Location: Hessen, Germany

Re: config variable in textstring

Post by Holger » Tue May 05, 2020 9:20 am

Tata wrote:
Mon May 04, 2020 10:22 pm
Wo finde ich eine Anleitung, ...
Zum Beispiel hier:
https://www.php.net/manual/en/function.sprintf.php und unter den dort weiter verlinkten String-Funktionen.

Tata
Posts: 3587
Joined: Tue May 20, 2008 5:34 am
Location: Slovakia
Contact:

Re: config variable in textstring

Post by Tata » Tue May 05, 2020 9:52 am

Hm, mit

Code: Select all

$plugin_tx['sitr']['text_before_start']="Program starts at %g hr.";
or
$plugin_tx['sitr']['text_before_start']="Program starts at %s hr.";
...
$plugin_cf['sitr']['event_start_time']="11:55";
und

Code: Select all

sprintf($plugin_tx['sitr']['text_before_announcement'],$plugin_cf['sitr']['event_start_time'])
Bekomme ich
Program starts at %g hr. 11:55
or
Program starts at %s hr. 11:55
EDIT: Ich weiß nicht wieso, aber es funktioniert schon.
Vielen Dank, Holger.
CMSimple.sk
It's no shame to ask for an answer if all efforts failed.
But it's awful to ask without any effort to find the answer yourself.

Post Reply