MyBB.de Forum

Normale Version: code auslagern
Du siehst gerade eine vereinfachte Darstellung unserer Inhalte. Normale Ansicht mit richtiger Formatierung.
Seiten: 1 2
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
(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?
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
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)
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!
Seiten: 1 2