MyBB.de Forum
code auslagern - Druckversion

+- MyBB.de Forum (https://www.mybb.de/forum)
+-- Forum: Sonstiges (https://www.mybb.de/forum/forum-1.html)
+--- Forum: Programmierung (https://www.mybb.de/forum/forum-32.html)
+--- Thema: code auslagern (/thread-31897.html)

Seiten: Seiten: 1 2


RE: code auslagern - hkkp - 21.04.2015

in dem template hab ich ihn rausgenommen, dort schaut es so aus:

PHP-Code:
<tr>
 <
td class="trow1"><div id="shoutbox_data" style="height: {$mybb->settings[sf_sb_height]}px; overflow:hidden;">{$lang->sf_sb_loading}</div></td>
</
tr>
<
tr>
 <
td class="trow1" align="left">EingabeMax42 Zeichen<form onsubmit="ShoutBox.postShout(); jQuery('#shout_data').val(''); return false;" action="index.php"><input type="text" style="font-size:1.2em;" id="shout_data" size="25" maxlength="42"/><input type="submit" name="" value="Los" id="shouting-status" /></form></td>
</
tr



RE: code auslagern - StefanT - 21.04.2015

(20.04.2015, 19:44)StefanT schrieb: Der Teil mit den PHP-Variablen wird sich kaum auslagern lassen.
Lass doch erst einmal alles im Templates bis es funktioniert?


RE: code auslagern - hkkp - 21.04.2015

so habe dies jetzt wieder ins template gepackt:

PHP-Code:
<script type="text/javascript">
//<![CDATA[
ShoutBox.refreshInterval = {$mybb->settings[sf_sb_refresh_interval]};
ShoutBox.MaxEntries = {$mybb->settings[sf_sb_shouts_main]};
ShoutBox.lang = ['{$lang->sf_sb_posting}''{$lang->sf_sb_shoutnow}''{$lang->sf_sb_loading}''{$lang->sf_sb_flood_check}'"{$lang->sf_sb_no_perform}"];
{
$extra_js}
//]]>
</script

dann kommt folgendes:

line 487 column 30 - Fehler: document type does not allow element "script" here


RE: code auslagern - StefanT - 21.04.2015

Dann liegt es überhaupt nicht am Inhalt des script-Elements sondern an der Platzierung.
Bei SELFHTML kannst du nachlesen, in welchen Elementen script verwendet werden darf: http://wiki.selfhtml.org/wiki/Referenz:HTML/script (Elternelemente)


RE: code auslagern - hkkp - 21.04.2015

also müßte es theoretisch ausreichen, wenn ich den jquery code auslagere und den rest per tr, td mit einbinde oder?

PHP-Code:
<tr>
 <
td class="trow1"><div id="shoutbox_data" style="height: {$mybb->settings[sf_sb_height]}px; overflow:hidden;">{$lang->sf_sb_loading}</div></td>
</
tr>
<
tr>
 <
td class="trow1" align="left">EingabeMax42 Zeichen<form onsubmit="ShoutBox.postShout(); jQuery('#shout_data').val(''); return false;" action="index.php"><input type="text" style="font-size:1.2em;" id="shout_data" size="25" maxlength="42"/><input type="submit" name="" value="Los" id="shouting-status" /></form></td>
</
tr>
<
tr>
<
td>
<
script type="text/javascript">
//<![CDATA[
ShoutBox.refreshInterval = {$mybb->settings[sf_sb_refresh_interval]};
ShoutBox.MaxEntries = {$mybb->settings[sf_sb_shouts_main]};
ShoutBox.lang = ['{$lang->sf_sb_posting}''{$lang->sf_sb_shoutnow}''{$lang->sf_sb_loading}''{$lang->sf_sb_flood_check}'"{$lang->sf_sb_no_perform}"];
{
$extra_js}
//]]>
</script>
</
td>
</
tr

PHP-Code:
<tr>
 <
td class="trow1"><div id="shoutbox_data" style="height: {$mybb->settings[sf_sb_height]}px; overflow:hidden;">{$lang->sf_sb_loading}</div></td>
</
tr>
<
tr>
<
td class="trow1" align="left">
EingabeMax42 Zeichen
<form onsubmit="ShoutBox.postShout(); jQuery('#shout_data').val(''); return false;" action="index.php"><input type="text" style="font-size:1.2em;" id="shout_data" size="25" maxlength="42"/><input type="submit" title="Los" value="Los" id="shouting-status" />
</
form>
</
td>
</
tr>
<
tr style="display:none">
<
td>
<
script type="text/javascript">
//<![CDATA[
ShoutBox.refreshInterval = {$mybb->settings[sf_sb_refresh_interval]};
ShoutBox.MaxEntries = {$mybb->settings[sf_sb_shouts_main]};ShoutBox.lang = ['{$lang->sf_sb_posting}''{$lang->sf_sb_shoutnow}''{$lang->sf_sb_loading}''{$lang->sf_sb_flood_check}'"{$lang->sf_sb_no_perform}"];
{
$extra_js}
//]]>
</script>
</
td>
</
tr

- dazu jquery ausgelagert
- funktioniert nun alles wie es soll

danke Stefan, den tipp werd ich mir merken!