la variable {$post['pid']} la saca como tendria que ser, en cuanto a esto no hay problema ya que asi esta programado y es PHP
para meter mas cosas al sistema (MyBB, un sistema de foros) yo uso find_replace desde PHP pero por el momento (solo para estar testeando) agrego las funciones y lo que me indicas directamente al sistema de templates (cual si fuera wordpress (para que te des una idea mas general))
yo a la plantilla agrego esto
Código Javascript
:
Ver originalfunction union() {
var uno = thx({$post['pid']});
var dos = hideuntilthanks_reload();
return uno && dos;
}
tal cual tu me lo indicaste, hasta ahi vamos bien,
al plugin/extension/hack en PHP yo agrego esto
Código PHP:
Ver original$post['thanks'] = "<a id=\"a{$post['pid']}\" onclick=\"return union()\" href=\"showthread.php?action=thank&tid={$post['tid']}&pid={$post['pid']}\">
<img src=\"{$mybb->settings['bburl']}/{$theme['imgdir']}/postbit_thx.gif\" border=\"0\" alt=\"$lang->thx_main\" title=\"$lang->thx_main\" id=\"i{$post['pid']}\" /></a>";
y en el archivo.js yo agrego lo que me indicaste (el alert) asi
Código Javascript
:
Ver originalfunction thx(id)
{
if(spinner)
return false;
spinner = new ActivityIndicator("body", {image: "images/spinner_big.gif"});
pid=id;
pb="pid="+pid;
alert('thx' + pid);
table = document.getElementById('thx' + pid);
new Ajax.Request('xmlhttp.php?action=thankyou',{method: 'post',postBody:pb, onComplete:thx_action});
return false;
}
Ahi me marca el error
table is null y
thxundefined (en 2 popups distintos) y no realiza la accion (almenos en AJAX, osea que marca el error y al darle Aceptar, recarga la pagina)
cuando yo uso
Código PHP:
Ver original$post['thanks'] = "<a id=\"a{$post['pid']}\" onclick=\"return thx({$post['pid']})\" href=\"showthread.php?action=thank&tid={$post['tid']}&pid={$post['pid']}\">
<img src=\"{$mybb->settings['bburl']}/{$theme['imgdir']}/postbit_thx.gif\" border=\"0\" alt=\"$lang->thx_main\" title=\"$lang->thx_main\" id=\"i{$post['pid']}\" /></a>";
y el alert agregado en la funcion, me regresa esto en un popup:
thx1 (que se supone que es el ID que le corresponde y señal de que funciona como debe) y al final realiza su funcion tal cual deveria (sin el reload)