|
|
| |
Forums ⇒ DragonflyCMS ⇒ Add-Ons & Blocks :: Archives ⇒ Getlink and javascript :: Archived
Getlink and javascript :: ArchivedNeed help creating a block or add-on, or you have created or modified a block/add-on that works in Dragonfly CMS and it meets the CPG Security Requirements? Do you have feedback about a specific add-on? Here is the place to post. Read the announcements here first!.
| Topic Archived |
View previous topic :: View next topic |
| Author |
Message |
fesja Newbie


Offline Joined: Apr 24, 2004 Posts: 49 Location: Madrid - Spain
|
Posted: Sun Dec 05, 2004 7:09 pm Post subject: Getlink and javascript |
|
Hi,
I have the following code:
| Code:: |
echo "<script language=\"Javascript\">
<!--
function delCom(id,nombre) {
var msg = '¿Quieres borrar este comentario (id:' + id + ')?';
if (confirm(msg)){
var url = 'Ediciones&op=borrarcoment&id='+id+'&carta='+nombre;
parent.document.location.href = ".getlink(url).";
}
}
--></script>"; |
The href doesn't function. What can i do? I have the LEO on, so writing 'index.php?name.....' doesn't function neither.
Thanks a lot
fesja's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS) Ubuntu Hoary / 2.0.53 / 4.1.10 / 4.3.10/ 9.0.3
|
|
| Back to top |
|
 |
fesja Newbie


Offline Joined: Apr 24, 2004 Posts: 49 Location: Madrid - Spain
|
Posted: Sun Dec 05, 2004 10:59 pm Post subject: Re: Getlink and javascript |
|
Another question:
My module is divided in functions, so depending what variable arrives it goes to one function or another.
But I've noticed that in some functions, i have to delete the name of the module from the getlink. For example:
| Code:: |
Header("Location: ".getlink('carta='.$nombre2)); |
If I write:
| Code:: |
Header("Location: ".getlink('Ediciones&carta='.$nombre2)); |
it goes to .../Ediciones/Ediciones/carta=....html.
It happens the same with the images. I have to write the urls like this:
| Code:: |
<img src=\"../images/cartas/0.gif\" alt=\"0\" title=\"0\"> |
If not the url of the image would be:
| Code:: |
url -> myserver/Ediciones/images/cartas/0.gif |
What can i be doing wrong? Maybe it's the first part when i assigned the variables that comes. The code of the first part is this:
| Code:: |
if(isset($_GET['nombre']) ? $_GET['nombre'] : ''){
$nombre = isset($_GET['nombre']) ? $_GET['nombre'] : ''; //Caracteristicas Edicion
edicion($nombre);
}else if(isset($_GET['avance']) ? $_GET['avance'] : ''){
$nombre = isset($_GET['avance']) ? $_GET['avance'] : ''; //Avance edicion
avance($nombre);
}else if(isset($_GET['faq']) ? $_GET['faq'] : ''){
$nombre = isset($_GET['faq']) ? $_GET['faq'] : ''; //FAQ
faq($nombre);
}else if(isset($_GET['spoiler']) ? $_GET['spoiler'] : ''){
$spoiler = isset($_GET['spoiler']) ? $_GET['spoiler'] : ''; //Spoiler
spoiler($spoiler);
}else if(isset($_GET['carta']) ? $_GET['carta'] : ''){
$carta = isset($_GET['carta']) ? $_GET['carta'] : ''; //Carta
vercarta($carta);
}else if(isset($_GET['op'])){
$op = $_GET['op']; //OP - Varias funciones
if($op == 'addcomentario' ){ //Añadir comentario
$idcarta = $_POST['idcarta'];;
$carta = $_POST['carta'];;
$autor = $_POST['autor'];;
$comentario2 = $_POST['comentario2'];;
$puntuacion = $_POST['puntuacion'];
addcomentario($idcarta, $carta, $autor, $comentario2, $puntuacion);
}else if($op == 'borrarcoment' ){ //Borrar comentario
$carta = $_GET['carta'];
$id = $_GET['id'];
borrarcoment($carta, $id);
}else if($op == 'cl' ){ //Checklist
$id = $_GET['id'];
cl($id);
}else if($op == 'editc' ){ //Editar
$cid = isset($_GET['cid']) ? $_GET['cid'] : '';
editc($cid);
}else if($op == 'save' ){ //Guardar edicion
$numero = $_POST['numero'];
$nombre = $_POST['nombre'];
$nme = $_POST['nme'];
$ver = $_POST['ver'];
$coste = $_POST['coste'];
$mana = $_POST['mana'];
$color = $_POST['color'];
$tipo = $_POST['tipo'];
$subtipo = $_POST['subtipo'];
$frec = $_POST['frec'];
$texto = $_POST['texto'];
$lit = $_POST['lit'];
$reglas = $_POST['reglas'];
$ilus = $_POST['ilus'];
$fr = $_POST['fr'];
$ciclo = $_POST['ciclo'];
$l_est = $_POST['l_est'];
$l_ext = $_POST['l_ext'];
$l_vint = $_POST['l_vint'];
$l_leg = $_POST['l_leg'];
$l_blo = $_POST['l_blo'];
$cid = $_POST['cid'];
save($numero, $nombre, $nme, $ver, $coste, $mana, $color, $tipo, $subtipo, $frec, $texto,
$lit, $reglas, $ilus, $fr, $ciclo, $l_est, $l_ext, $l_vint, $l_leg, $l_blo, $cid);
}else if($op == 'save_comentario' ){ //Guardar comentario
$idcarta = $_POST['idcarta'];;
$carta = $_POST['carta'];;
$id = $_POST['id'];;
$comentario = $_POST['comentario'];;
$puntuacion = $_POST['puntuacion'];
save_comentario($idcarta, $carta, $id, $comentario, $puntuacion);
}else if($op == 'sp' ){ //Spoiler en texto
$id = $_GET['id'];
sp($id);
}else if($op == 'vercartaid'){ //verCarta por ID
$cid = $_GET['cid'];
verCartaId($cid);
}else if($op == 'vercartan'){ //verCarta por Nombre
if(isset($_GET['nombre']) ? $_GET['nombre'] : ''){
$nombre = isset($_GET['nombre']) ? $_GET['nombre'] : '';//Carta
}else{
$nombre = $_POST['nombre'];
}
if(isset($_GET['ed']) ? $_GET['ed'] : ''){
$ed = isset($_GET['ed']) ? $_GET['ed'] : '';//Carta
}
verCartaN($nombre, $ed);
}else if($op == 'codigos'){ //Codigos para edicion
codigos();
}
}else{
ediciones(); //Lista de ediciones
} |
i changed this today for the dragonfly, so maybe i'm wrong on many things
Thanks a lot.
fesja's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS) Ubuntu Hoary / 2.0.53 / 4.1.10 / 4.3.10/ 9.0.3
|
|
| Back to top |
|
 |
Phoenix • Many Posts •


Offline Joined: Apr 19, 2004 Posts: 8799 Location: Netizen
|
Posted: Mon Dec 06, 2004 4:15 am Post subject: Re: Getlink and javascript |
|
Don't use header location, use,
url_redirect(getlink('whatever'));
_________________ • DonationsPro for DragonflyCMS, SMF, MyBB, vBulletin •
Phoenix's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
|
|
| Back to top |
|
 |
Śyama_Dāsa Developer


Offline Joined: Apr 19, 2004 Posts: 2048 Location: Dragonfly CMS Tribe
|
Posted: Mon Dec 06, 2004 6:35 am Post subject: Re: Getlink and javascript |
|
not sure if this helps but i have had issues with javascript and ¿
when using getlink and js you also should also use the "full" url switch
| Code:: |
getlink($url="", $UseLEO=true, $full=false) |
| Code:: |
getlink("Link", 1, 1) |
_________________ AKA Akamu / Read these and your life will be successful | Find a Repair
--
Mods and Professional Support via YIM
Śyama_Dāsa's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS) win32 / Apache 1.3.33 / MySQL 4.1.16/PHP 4.4/CPG-CVS ( browsers: Mozilla 1.7.x / IE6 / Opera 8.0)
|
|
| Back to top |
|
 |
fesja Newbie


Offline Joined: Apr 24, 2004 Posts: 49 Location: Madrid - Spain
|
Posted: Mon Dec 06, 2004 10:49 am Post subject: Re: Getlink and javascript |
|
Thanks phoenix. I've already change all my headers.
Thanks akamu, but I already have the same problem. How do I write this:
| Code:: |
echo "<script language=\"javascript\">
function cambioversion( ver ) {
window.location.href = '".getlink('Ediciones&carta='.$nombre.'&ed=+ver',1,1).";
}</script>"; |
Where and how do i have to write the variable ver, with '', or "" or without anything. I've tried many things and didnt function.
And if i write in the getlink function $full=1 what happens. What is the difference between $full=0 and $full=1 ??
Thanks
fesja's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS) Ubuntu Hoary / 2.0.53 / 4.1.10 / 4.3.10/ 9.0.3
|
|
| Back to top |
|
 |
Phoenix • Many Posts •


Offline Joined: Apr 19, 2004 Posts: 8799 Location: Netizen
|
Posted: Mon Dec 06, 2004 12:17 pm Post subject: Re: Getlink and javascript |
|
includes/functions/linking.php,
function getlink($url='', $UseLEO=true, $full=false)
if ($full) $url = $BASEHREF.$url;
Personally, I have also had troubles with js, and find it easier to just use the normal url link.
Phoenix's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
|
|
| Back to top |
|
 |
fesja Newbie


Offline Joined: Apr 24, 2004 Posts: 49 Location: Madrid - Spain
|
Posted: Mon Dec 06, 2004 1:11 pm Post subject: Re: Getlink and javascript |
|
So you recommend me not to do any js link. Ok.
Thanks a lot
fesja's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS) Ubuntu Hoary / 2.0.53 / 4.1.10 / 4.3.10/ 9.0.3
|
|
| Back to top |
|
 |
Phoenix • Many Posts •


Offline Joined: Apr 19, 2004 Posts: 8799 Location: Netizen
|
Posted: Mon Dec 06, 2004 1:14 pm Post subject: Re: Getlink and javascript |
|
Well, if you can't get getlink to work with those parameters, you don't have much choice.
Phoenix's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
|
|
| Back to top |
|
 |
DJ Maze Developer


Offline Joined: Apr 19, 2004 Posts: 5683 Location: http://tinyurl.com/5z8dmv
|
Posted: Mon Dec 06, 2004 2:15 pm Post subject: Re: Getlink and javascript |
|
IF your JS has trouble you can prevent getlink from using LEO: getlink('url', false, true)
DJ Maze's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS) Fedora 15 / 2.2.22 / 5.5.20 / 5.3.10 / CVS
|
|
| Back to top |
|
 |
fesja Newbie


Offline Joined: Apr 24, 2004 Posts: 49 Location: Madrid - Spain
|
Posted: Mon Dec 06, 2004 3:55 pm Post subject: Re: Getlink and javascript |
|
The problem is not with LEO, it is with getlink becuse i dont know how to add javascript variables to the getlink. If there is not solution i've no choice as phoenix said
fesja's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS) Ubuntu Hoary / 2.0.53 / 4.1.10 / 4.3.10/ 9.0.3
|
|
| Back to top |
|
 |
DJ Maze Developer


Offline Joined: Apr 19, 2004 Posts: 5683 Location: http://tinyurl.com/5z8dmv
|
Posted: Mon Dec 06, 2004 4:28 pm Post subject: Re: Getlink and javascript |
|
You can but it needs you to properly use javascript.
let the PHP output javascript like this:
| PHP: |
echo "var url = '".getlink("Ediciones&op=borrarcoment&id='+id+'&carta='+nombre+'")."';";
|
This should return something like:
| Code:: |
var url = 'Ediciones/op=borrarcoment/id='+id+'/carta='+nombre+'.html'; |
or
| Code:: |
var url = 'index.php?name=Ediciones&op=borrarcoment&id='+id+'&carta='+nombre+''; |
depending if LEO is active or not
DJ Maze's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS) Fedora 15 / 2.2.22 / 5.5.20 / 5.3.10 / CVS
|
|
| Back to top |
|
 |
fesja Newbie


Offline Joined: Apr 24, 2004 Posts: 49 Location: Madrid - Spain
|
Posted: Mon Dec 06, 2004 5:42 pm Post subject: Re: Getlink and javascript |
|
It happens a strange thing. I have the following code:
As I have now it works perfect, but if i DONT write $BASEHREF before getlink, when i change the select option it goes to the following page the first time i change:
| Code:: |
myserver/Ediciones/op=verCartaId/Ediciones/op=verCartaId/cid=10177.html |
in this new page i change again, and it goes to:
| Code:: |
myserver/Ediciones/op=verCartaId/Ediciones/op=verCartaId/Ediciones/op=verCartaId/cid=10182.html |
and i change again:
| Code:: |
myserver/Ediciones/op=verCartaId/Ediciones/op=verCartaId/Ediciones/op=verCartaId/Ediciones/op=verCartaId/cid=10269.html |
and the i change the last time and i geta 500 internal error.
I've the problem solved but maybe i did something wrong before or the getlink has a bug.
thanks a lot.
Javier
fesja's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS) Ubuntu Hoary / 2.0.53 / 4.1.10 / 4.3.10/ 9.0.3
|
|
| Back to top |
|
 |
DJ Maze Developer


Offline Joined: Apr 19, 2004 Posts: 5683 Location: http://tinyurl.com/5z8dmv
|
Posted: Mon Dec 06, 2004 6:38 pm Post subject: Re: Getlink and javascript |
|
as mentioned the 3rd parameter must be set to TRUE
getlink('url', true, true);
my code was an example this means you could have figured out the 2 other options in getlink() as mentioned by akamu here
And you also see that javascript can't handle <base href> as mentioned in the forums here
DJ Maze's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS) Fedora 15 / 2.2.22 / 5.5.20 / 5.3.10 / CVS
|
|
| Back to top |
|
 |
fesja Newbie


Offline Joined: Apr 24, 2004 Posts: 49 Location: Madrid - Spain
|
|
| Back to top |
|
 |
|
|
|
| |
 |
 Welcome Anonymous
|
|
|
|