Willkommen auf dem Portal für Mediengestalter
|
|
Autor |
Nachricht |
chrisegeland
Dabei seit: 25.12.2008
Ort: -
Alter: -
Geschlecht: -
|
Verfasst Sa 20.06.2009 19:16
Titel
|
|
|
So hatte ich es auch schon versucht, also ich habe eine ajax_reload.php die wie folgt aussieht:
Code: |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Ajax Reload</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="mootools-1.2.3-core-yc.js"></script>
<script type="text/javascript">
<!--
var updater, updateInterval;
window.addEvent('domready', function() {
updater = new Request.HTML({
url: 'script.php',
update: $('dropzone'),
evalScripts : 'true'
}).send();
updateInterval = function() {
$('dropzone').empty();
this.send();
};
updateInterval.periodical(4000, updater);
});
-->
</script>
</head>
<body>
<div id="dropzone">
wdawdadaw
</div>
</body>
</html>
|
Und dann eine script.php mit folgendem Code:
Code: |
<?php
$adTags = array(
array('height' => '60', 'zone_id' => 2),
array('height' => '120', 'zone_id' => 3),
array('height' => '180', 'zone_id' => 4),
array('height' => '300', 'zone_id' => 5),
array('height' => '600', 'zone_id' => 6)
);
$maxHeight = 600;
$height = 0;
$result = array();
while ($height < $maxHeight) {
// index für $adtags wählen
$i = rand(0, count($adTags)-1);
//prüfen ob ausgeählte Zone von der Höhe noch reinpasst
if ($height + $adTags[$i]['height'] <= $maxHeight) {
$result[] = $adTags[$i]['zone_id'];
$height += $adTags[$i]['height'];
}
}
shuffle($result);
?>
<?php
echo "
<script type='text/javascript'>
var OA_zones = {
";
$n = 0;
foreach($result as $zone_id) {
if ($n++) {
echo ",\n";
}
echo "'place{$n}' : {$zone_id}";
}
echo "
}
</script>
<script type='text/javascript' src='http://localhost/openx/www/delivery/spcjs.php'></script>
";
?>
<?php
echo "
<script type='text/javascript'>
";
$n = 1;
foreach($result as $zone_id) {
echo "OA_show('place{$n}');";
$n++;
}
echo "
</script>
";
echo "
<script type='text/javascript' src='http://localhost/openx/www/delivery/spcjs.php'></script>
";
?>
<?php
echo '<!-- verify - remove in production --- ';
$finalHeight = 0;
foreach($result as $zone_id) {
foreach($adTags as $tagInfo) {
if ($tagInfo['zone_id'] == $zone_id) {
$finalHeight += $tagInfo['height'];
}
}
}
echo 'total height is '.$finalHeight;
echo ' --- end verify -->';
?>
|
Allein ausgeführt spuckt die script.php das ganze korrekt aus. Nur die ajax_reload.php liefert keinen Output. Hat das vielleicht damit zu tun, dass bestimmte Anweisungen im Head stehen müssten, jetzt werden diese ja in die div gedropt. Dieser Teil müsste laut OpenX Forum im Head stehen:
Code: |
<?php
$adTags = array(
array('height' => '60', 'zone_id' => 2),
array('height' => '120', 'zone_id' => 3),
array('height' => '180', 'zone_id' => 4),
array('height' => '300', 'zone_id' => 5),
array('height' => '600', 'zone_id' => 6)
);
$maxHeight = 600;
$height = 0;
$result = array();
while ($height < $maxHeight) {
// index für $adtags wählen
$i = rand(0, count($adTags)-1);
//prüfen ob ausgeählte Zone von der Höhe noch reinpasst
if ($height + $adTags[$i]['height'] <= $maxHeight) {
$result[] = $adTags[$i]['zone_id'];
$height += $adTags[$i]['height'];
}
}
shuffle($result);
?>
<?php
echo "
<script type='text/javascript'><!--// <![CDATA[
var OA_zones = {
";
$n = 0;
foreach($result as $zone_id) {
if ($n++) {
echo ",\n";
}
echo "'place{$n}' : {$zone_id}";
}
echo "
}
// ]]> --></script>
<script type='text/javascript' src='http://localhost/openx/www/delivery/spcjs.php'></script>
";
?>
|
Danke schon mal!
|
|
|
|
|
zweitaccount
Dabei seit: 25.01.2008
Ort: -
Alter: -
Geschlecht: -
|
Verfasst Sa 20.06.2009 20:31
Titel
|
|
|
Hmm, ganz steig ich ehrlich gesagtnoch nicht dahinter
wie das funktioniert mit dieser Bannerauslieferung.
Versuchs mal so. Dieses hier auf auf deiner
ajax_reload.php ganz am Anfang vor dem <doctype>
Code: | <?php
session_start();
$adTags = array(
array('height' => '60', 'zone_id' => 2),
array('height' => '120', 'zone_id' => 3),
array('height' => '180', 'zone_id' => 4),
array('height' => '300', 'zone_id' => 5),
array('height' => '600', 'zone_id' => 6)
);
$maxHeight = 600;
$height = 0;
$result = array();
while ($height < $maxHeight) {
// index für $adtags wählen
$i = rand(0, count($adTags)-1);
//prüfen ob ausgeählte Zone von der Höhe noch reinpasst
if ($height + $adTags[$i]['height'] <= $maxHeight) {
$result[] = $adTags[$i]['zone_id'];
$height += $adTags[$i]['height'];
}
}
shuffle($result);
$_SESSION['result'] = $result;
?>
|
Ab hier sollten die gemischten Results in einer
Sessionvariable verfügbar sein. Dann im <head>
von deiner ajax_reload.php dann dieses hier:
Code: | <?php
echo "
<script type='text/javascript'><!--// <![CDATA[
var OA_zones = {
";
$n = 0;
foreach($result as $zone_id) {
if ($n++) {
echo ",\n";
}
echo "'place{$n}' : {$zone_id}";
}
echo "
}
// ]]> --></script>
<script type='text/javascript' src='http://localhost/openx/www/delivery/spcjs.php'></script>
";
?> |
Und dieser Part wäre in der script.php unterzubringen:
Code: | <?php
session_start();
echo "
<script type='text/javascript'>
";
$n = 1;
foreach($_SESSION['result'] as $zone_id) {
echo "OA_show('place{$n}');";
$n++;
}
echo "
</script>
";
echo "
<script type='text/javascript' src='http://localhost/openx/www/delivery/spcjs.php'></script>
";
?> |
Das verify-Zeugs erstmal weglassen, sonst
müsstes Du die $adTags auch via Session rüber-
bringen.
Ansonsten wärs wahrscheinlich hilfreich wenn Du
Dir den Firebug o.ä. installierst, dann kannst Du
auf einen Blick sehen, welches Javascript Fehler
produziert und so dann den Fehler eingrenzen...
Grüße
|
|
|
|
|
Anzeige
|
|
|
chrisegeland
Dabei seit: 25.12.2008
Ort: -
Alter: -
Geschlecht: -
|
Verfasst Mo 22.06.2009 20:27
Titel
|
|
|
hi zweitaccount!
ich habe das soeben versucht, die banner werden nun angezeigt, allerdings erfolgt kein reload.
firebug hatte bei erster methode keine js fehler angezeigt, bei der neuen methode zeigt er einen fehler "clone.getElementsByTagName is not a function"
der reload hatte in der ersten version auch geklappt, das sieht man ja im firebug, dass alle 8 sekunden der html bereich gereloaded wird, aber aus irgendeinem grund wurde es nicht in die div geladen.
der quelltext bei der neuen methode sieht wie folgt aus:
Code: |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Ajax Reload</title>
<script type='text/javascript'><!--// <![CDATA[
var OA_zones = {
'place1' : 3,
'place2' : 2,
'place3' : 5,
'place4' : 3
}
// ]]> --></script>
<script type='text/javascript' src='http://localhost/openx/www/delivery/spcjs.php'></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="mootools-1.2.3-core-nc.js"></script>
<script type="text/javascript">
<!--
var updater, updateInterval;
window.addEvent('domready', function() {
updater = new Request.HTML({
url: 'script.php',
update: $('dropzone'),
evalScripts : 'true'
}).send();
updateInterval = function() {
$('dropzone').empty();
this.send();
};
updateInterval.periodical(4000, updater);
});
-->
</script>
</head>
<body>
<div id="dropzone">
</div>
</body>
</html>
|
|
|
|
|
|
zweitaccount
Dabei seit: 25.01.2008
Ort: -
Alter: -
Geschlecht: -
|
Verfasst Mo 22.06.2009 21:19
Titel
|
|
|
Hi chrisegeland,
jetzt bin ich mit meinem Latein dann auch am Ende.
K.A. wie das javascript aussieht, dass da in dieser
Zeile ausgeliefert wird:
http://localhost/openx/www/delivery/spcjs.php
Ein Versuch aber noch. Lade dir mal die Mootools Extension
'Assets' runter und lade die nach dem mootools-core:
http://mootools.net/more
Hier noch die Docu dazu:
http://mootools.net/docs/more/Utilities/Assets
Und dann häng an den updater noch folgenden
onComplete-Event dran:
Code: | <script type="text/javascript">
<!--
var updater, updateInterval;
window.addEvent('domready', function() {
updater = new Request.HTML({
url: 'script.php',
update: $('dropzone'),
evalScripts : 'true',
onComplete: function() {
var myScript = new Asset.javascript('http://localhost/openx/www/delivery/spcjs.php');
}
}).send();
updateInterval = function() {
$('dropzone').empty();
this.send();
};
updateInterval.periodical(4000, updater);
});
-->
</script>
|
Wenn also die Banner in der Dropzone angekommen
sind, läd das Script via new Asset das OpenX-Script
nach. Demnach müsste dann in deiner script.php
das hier ersatzlos raus:
Code: | <script type='text/javascript' src='http://localhost/openx/www/delivery/spcjs.php'></script> |
Und dann Daumen drücken + Reload
|
|
|
|
|
chrisegeland
Dabei seit: 25.12.2008
Ort: -
Alter: -
Geschlecht: -
|
Verfasst Mo 22.06.2009 21:44
Titel
|
|
|
Ok, danke für den Tip. Werd ich gleich mal probieren. Du meinst aber Methode eins plus die Assets Extension, oder?
|
|
|
|
|
chrisegeland
Dabei seit: 25.12.2008
Ort: -
Alter: -
Geschlecht: -
|
Verfasst Mo 22.06.2009 22:02
Titel
|
|
|
Habe es gerade versucht, hat leider nicht geklappt. Ich denke ich werde mich mal im OpenX Forum melden. Du kannst ja nicht wissen, wie das mit der Bannerauslieferung funktioniert, vll. können die mir da helfen. Die http://localhost/openx/www/delivery/spcjs.php sieht im übrigen so aus:
Code: |
if (typeof(OA_zones) != 'undefined') {
var OA_zoneids = '';
for (var zonename in OA_zones) OA_zoneids += escape(zonename+'=' + OA_zones[zonename] + "|");
OA_zoneids += '&nz=1';
} else {
var OA_zoneids = escape('');
}
if (typeof(OA_source) == 'undefined') { OA_source = ''; }
var OA_p=location.protocol=='https:'?'https:':'http:';
var OA_r=Math.floor(Math.random()*99999999);
OA_output = new Array();
var OA_spc="<"+"script type='text/javascript' ";
OA_spc+="src='"+OA_p+"//localhost/openx/www/delivery/spc.php?zones="+OA_zoneids;
OA_spc+="&source="+escape(OA_source)+"&r="+OA_r;
OA_spc+=(document.charset ? '&charset='+document.charset : (document.characterSet ? '&charset='+document.characterSet : ''));
if (window.location) OA_spc+="&loc="+escape(window.location);
if (document.referrer) OA_spc+="&referer="+escape(document.referrer);
OA_spc+="'><"+"/script>";
document.write(OA_spc);
function OA_show(name) {
if (typeof(OA_output[name]) == 'undefined') {
return;
} else {
document.write(OA_output[name]);
}
}
function OA_showpop(name) {
zones = window.OA_zones ? window.OA_zones : false;
var zoneid = name;
if (typeof(window.OA_zones) != 'undefined') {
if (typeof(zones[name]) == 'undefined') {
return;
}
zoneid = zones[name];
}
var OA_pop="<"+"script type='text/javascript' ";
OA_pop+="src='"+OA_p+"//localhost/openx/www/delivery/apu.php?zoneid="+zoneid;
OA_pop+="&source="+escape(OA_source)+"&r="+OA_r;
if (window.location) OA_pop+="&loc="+escape(window.location);
if (document.referrer) OA_pop+="&referer="+escape(document.referrer);
OA_pop+="'><"+"/script>";
document.write(OA_pop);
}
var OA_fo = '';
OA_fo += "<"+"script type=\'text/javascript\' src=\'http://localhost/openx/www/delivery/fl.js\'><"+"/script>\n";
document.write(OA_fo);
|
Vielen Dank trotzdem für deine Hilfe!
|
|
|
|
|
|
|
|
Ähnliche Themen |
JavaScript select/option switch ohne reload
[javascript] variablen mit mehrzeiligem inhalt
[javascript] div inhalt ändern - auf die andere art
Anzeige von Inhalt nur bei aktiviertem Javascript
[JavaScript] Fenstergröße dem Inhalt anpassen
Bei Klick in Formularfeld Inhalt löschen.. - JavaScript?
|
|
|
Du kannst keine Beiträge in dieses Forum schreiben. Du kannst auf Beiträge in diesem Forum nicht antworten. Du kannst an Umfragen in diesem Forum nicht mitmachen.
|
|