Hi Tom,
On 18/02/2009, at 12:46 AM, Martín Gaitán wrote:
Hi Tom
I've implemented something like you want in my weblog: For example.
http://www.textosypretextos.com.ar/Felices-Quince
It's so simple. Just put this code inside <head></head> after the
calling to thickbox (if u include it manually) and #INSERT_HEAD:
<script>
//on page load call tb_init
$(document).ready(function(){
/* enlaces externos en nueva ventana */
$("a.spip_out").each(function(){
var alto = $(window).height()- Math.floor($(window).height()*0.2);
var ancho = $(window).width()-Math.floor($(window).width()*0.2);
this.title = this.href;
this.href += "?keepThis=true&TB_iframe=true&height=" + alto +
"&width=" + ancho;
tb_init(this); //recarga de thickbox
});
}); //end jquery ready()
</script>
A little explanation:
when you make a an external link in spip (the href begin with http)
spip add the class "spip_out". So, this jquery code selects every link
with spip_out and the extra parameter to open that link in modal
window. As last step relaunch thickbox for that link.
You could also use a model to generate the thinkbox link. This means that you can choose which links it gets applied to (including internal links).
The SPIP code in the articles, etc. looks like this:
[<link|texte=This is the text of the link>->http://www.google.com/\]
And you'll need to add a link model (probably squelettes/modeles/link.html) like this:
<a class="spip_lien_ok[ (#ENV{lien_classe})] thickbox" href="#ENV{lien}">#ENV{texte, #ENV{lien}}</a>
The "spip_lien_ok" is required to tell SPIP that the model has made the link (otherwise it'll wrap another <a> around it), the "#ENV{lien_classe}" is the spip_out, etc. you get on a normal SPIP link, and the "thickbox" can be whatever class you want for your javascript. "#ENV{lien}" is the URL for the link, and the "#ENV{texte, #ENV{lien}}" outputs the texte or, if it's missing, the URL.
This keeps everything in SPIP and under control of the editors and administrators without having to edit templates (or put Javascript in articles that the templates include). You'll still need to add the Thickbox CSS, Javascript, etc.
This has been tested on SPIP 1.9.2g and you can find more information on using models like this at <http://www.spip.net/en_article3512.html>\.
Regards,
Thomas Sutton
bouncingorange