Social Media
Foren
PlugIn entwicklung
naja das activate.php script scheint soweit zu funktionieren.
nur bei der ausgabe im dashboard happert es mal wieder bei mir siehe jpeg und code
[img]http://beratung.contentlion.de/index.php?page=Attachment&attachmentID=170&h=63f9a186ee04a71e5a70bad6f4cbba7ab1c69785[/img]
ausschnitt activate.php:
config.php:
configpage.html:
nur bei der ausgabe im dashboard happert es mal wieder bei mir siehe jpeg und code
[img]http://beratung.contentlion.de/index.php?page=Attachment&attachmentID=170&h=63f9a186ee04a71e5a70bad6f4cbba7ab1c69785[/img]
ausschnitt activate.php:
PHP-Quelltext |
|
1 2 3 |
WidgetController::register("Plugin_WowArmory_Config","WowArmory","wowarmory/config.php");
$row = DataBase::Current()->ReadField("SELECT IFNULL(MAX(row),0) + 1 FROM {'dbprefix'}dashboards WHERE col = 1");
DataBase::Current()->Execute("INSERT INTO `{'dbprefix'}dashboards` (alias,col,row,path) VALUES ('admin/home', 1, ".$row.", 'wowarmory/config.php');");
|
config.php:
PHP-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 |
<?php
class Plugin_WowArmory_Config extends WidgetBase{
public function load(){
$template = new Template();
$template->load = "plugin_wowarmory_configpage";
//$regionSelection = ;
$template->assign_var("REGION",Plugin_WowArmory_Regions::setRegion());
$template->getCode();
}
}
?>
|
configpage.html:
Quellcode |
|
1 2 3 4 5 6 7 8 |
<form method="post" action=""> <table> <tr> <td>Region:</td> <td>{VAR:REGION}</td> </tr> </table> </form> |
setRegion soll eigentlich nur eine übergabe der verfügbaren Regionen sein.
das kann man auch in der regions.php im classes ordner sehen
PHP-Quelltext |
|
1 2 3 4 5 6 7 8 9 |
static function setRegion(){
$selRegion =
'<option value="us">US</option>
<option value="europe">EU</option>
<option value="korea">KR</option>
<option value="taiwan">TW</option>
<option value="china">CN</option>';
return $selRegion;
}
|
das kann man auch in der regions.php im classes ordner sehen
ok, jetzt geht das widget erstmal.
aber ein neues problemchen
vielleicht liegt es am wetter oder ich stell mich zu ... an
ich möchte jetzt das ausgewählte value von der Region an
übergeben sodass dann bei
die optionen zum auswählen angezeigt werden.
hiermal die setHost funktion:
aber ein neues problemchen
vielleicht liegt es am wetter oder ich stell mich zu ... an
ich möchte jetzt das ausgewählte value von der Region an
PHP-Quelltext |
|
1 |
Plugin_WowArmory_Regions::setHost($region)
|
Quellcode |
|
1 2 3 4 |
<tr> <td>Host:</td> <td><select name="host" >{VAR:HOST}</select></td> </tr> |
die optionen zum auswählen angezeigt werden.
hiermal die setHost funktion:
PHP-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
static function setHost($region){
$region = $_GET['region'];
if($region){
if($region == 'us'){
$host = 'us.battle.net';
$localSelection =
'<option value="en_US">Amerika</option>
<option value="es_MX">Mexico</option>
<option value="pt_BR">Brasilien</option>';
$res = array($host, $localSelection);
}
elseif($region == 'europe'){
$host = 'eu.battle.net';
$localSelection =
'<option value="en_GB">England</option>
<option value="es_ES">Spanien</option>
<option value="fr_FR">Frankreich</option>
<option value="ru_RU">Russland</option>
<option value="de_DE">Deutschland</option>
<option value="pt_PT">Portugal</option>
<option value="it_IT">Italien</option>';
$res = array($host, $localSelection);
}
elseif($region == 'korea'){
$host = 'kr.battle.net';
$localSelection = '<option value="ko_KR">Korea</option>';
$res = array($host, $localSelection);
}
elseif($region == 'taiwan'){
$host = 'tw.battle.net';
$localSelection = '<option value="zh_TW">Taiwan</option>';
$res = array($host, $localSelection);
}
elseif($region == 'china'){
$host = 'www.battlenet.com.cn';
$localSelection = '<option value="zh_CN">China</option>';
$res = array($host, $localSelection);
}
}
return $res;
}
|
das mit dem array wollte ich eigentlich wieder wegnehmen hab's aber vergessen
hier nochmal die Zuweisung für das template
hier nochmal die Zuweisung für das template
PHP-Quelltext |
|
1 2 3 4 5 6 7 8 9 |
public function load(){
$template = new Template();
$template->load("plugin_wowarmory_configpage");
$this->headline = "WoW Armory Config";
//$regionSelection = ;
$template->assign_var("REGION",Plugin_WowArmory_Regions::setRegion());
$template->assign_var("HOST",Plugin_WowArmory_Regions::setHost($region));
$this->content = $template->getCode();
}
|
Guten Morgen zusammen,
ich komme mal wieder nicht weiter, ich habe mein Plugin für die Config auf eine DB Variante umgestellt, das klappt auch soweit, nur komme ich mit der übergabe der neuen daten an das Template nicht weiter, vielleicht habe ich auch nur eine falsche herangehensweise oder denke zu komplex.
Hier mal die Aktuellen snippets
Klasse regions.php
Klasse Config.php
Template Configpage.html
Vielleicht könnt Ihr mir ja mal wieder behilflich sein. Ich währe euch dafür sehr dankbar
MfG
PhaseV
ich komme mal wieder nicht weiter, ich habe mein Plugin für die Config auf eine DB Variante umgestellt, das klappt auch soweit, nur komme ich mit der übergabe der neuen daten an das Template nicht weiter, vielleicht habe ich auch nur eine falsche herangehensweise oder denke zu komplex.
Hier mal die Aktuellen snippets
Klasse regions.php
PHP-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
static function setRegion($selected){
$selRegion =
'<option value="us" '.if('us' == $selected){echo 'selected="selected"';}.'>US</option>
<option value="eu" '.if('eu' == $selected){echo 'selected="selected"';}.'>Europe</option>
<option value="kr" '.if('kr' == $selected){echo 'selected="selected"';}.'>Korea</option>
<option value="tw" '.if('tw' == $selected){echo 'selected="selected"';}.'>Taiwan</option>
<option value="cn" '.if('cn' == $selected){echo 'selected="selected"';}.'>China</option>';
return $selRegion;
}
static function setHost($region){
if(isset($region)){
if($region == 'us'){
$host = 'us.battle.net';
$res = $host;
}
elseif($region == 'eu'){
$host = 'eu.battle.net';
$res = $host;
}
elseif($region == 'kr'){
$host = 'kr.battle.net';
$localSelection = '<option value="ko_KR">Korea</option>';
$res = $host;
}
elseif($region == 'tw'){
$host = 'tw.battle.net';
$res = $host;
}
elseif($region == 'cn'){
$host = 'www.battlenet.com.cn';
$res = $host;
}
return $res;
}
}
|
Klasse Config.php
PHP-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
<?php
class Plugin_WowArmory_Config extends WidgetBase{
public function load(){
$template = new Template();
$template->load("plugin_wowarmory_configpage");
$this->headline = "WoW Armory Config";
global $HTTP_POST_VARS;
$region = $GLOBALS['db']->ReadField("SELECT name FROM {'dbprefix'}plugin_wowarmory_realm");
if(!isset($region)){
$template->assign_var("REGION",Plugin_WowArmory_Regions::setRegion());
}
if(isset($region)) {
$template->assign_var("REGION",Plugin_WowArmory_Regions::setRegion($region));
}
if(isset($_POST['region'])){
$GLOBALS['db']->Execute("INSERT INTO `{'dbprefix'}plugin_wowarmory_realm` (id, name) VALUES (1, '".$_POST['region']."') ON DUPLICATE KEY UPDATE name=name;");
}
$template->assign_var("HOST",Plugin_WowArmory_Regions::setHost($region));
$this->content = $template->getCode();
}
}
?>
|
Template Configpage.html
PHP-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
<table>
<th colspan="2">Realm Config</th>
<form name="rConf" method="post">
<tr>
<td>Region:</td>
<td><select name="region" onChange="document.forms['rConf'].submit();">{VAR:REGION}</select></td>
</tr>
<tr>
<td>Host:</td>
<td><select name="host" >{VAR:HOST}</select></td>
</tr>
</form>
</table>
<table>
<th colspan="2">Gilden Config</th>
<form method="post" action="">
<tr>
<td>Rang 0</td>
<td><input type="text" name="rank_0_name"></td>
</tr>
</form>
</table>
|
Vielleicht könnt Ihr mir ja mal wieder behilflich sein. Ich währe euch dafür sehr dankbar
MfG
PhaseV
PHP-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
<table>
<tbody><tr><th colspan="2">Realm Config</th>
<form name="rConf" method="post"></form>
</tr><tr>
<td>Region:</td>
<td><select name="region" onchange="document.forms['rConf'].submit();"><option value="us">US</option>
<option value="eu">Europe</option>
<option value="kr">Korea</option>
<option value="tw">Taiwan</option>
<option value="cn">China</option></select></td>
</tr>
<tr>
<td>Host:</td>
<td><select name="host"></select></td>
</tr>
<tr>
<td>Realm:</td>
<td><select name="realm">{VAR:REALM}</select></td>
</tr>
<tr>
<td>Gilde:</td>
<td><input name="guild" value="{VAR:GUILD}"></td>
</tr>
</tbody></table>
<table>
<tbody><tr><th colspan="2">Gilden Config</th>
<form method="post" action=""></form>
</tr><tr>
</tr>
</tbody></table>
|
ich musste aber erstmal die if abfragen bei $selRegion in der regions.php entfernen, da mir da ein
angezeigt wirdZitat
Parse error: syntax error, unexpected T_IF
Manches im Code geht gar nicht.
z.B. musst du statt
verwenden!
Ich würde auch an deiner Stelle kaum globale Variablen einsetzen.
Bei dem HTML Code fehlt vor dem selected schon mal ein Leerzeichen.
An deiner Stelle würde ich auch mal die Methoden etwas anders umbenennen, da man sonst vermutet, dass z.B. der Host gesetzt wird.
Stattdessen wird aber ein HTML Code zurückgegeben.
Sonst fällt mir jetzt nichts direkt auf, was nicht passt.
Was wird denn genau ausgegeben?
z.B. musst du statt
PHP-Quelltext |
|
1 |
$GLOBALS['db']
|
PHP-Quelltext |
|
1 |
DataBase::Current()
|
Ich würde auch an deiner Stelle kaum globale Variablen einsetzen.
Bei dem HTML Code fehlt vor dem selected schon mal ein Leerzeichen.
An deiner Stelle würde ich auch mal die Methoden etwas anders umbenennen, da man sonst vermutet, dass z.B. der Host gesetzt wird.
Stattdessen wird aber ein HTML Code zurückgegeben.
Sonst fällt mir jetzt nichts direkt auf, was nicht passt.
Was wird denn genau ausgegeben?
Ähnliche Themen
-
- Erweiterungen »
- JavaScript und Templates und ohje (6. Juni 2013, 19:05)
-
- Erweiterungen »
- Mein erstes Plugin (Analytics) (3. Juni 2013, 22:26)