Foros del Web » Programando para Internet » PHP »

RTE Editor

Estas en el tema de RTE Editor en el foro de PHP en Foros del Web. Alguien del foro ha utilizado el RTE Editor? Tengo un problema cuando quiero levantar una variable cualquiera de php como valor predeterminado (en realidad es ...
  #1 (permalink)  
Antiguo 07/03/2005, 10:51
 
Fecha de Ingreso: octubre-2004
Ubicación: En algún lugar de la República Oriental del Uruguay
Mensajes: 366
Antigüedad: 19 años, 6 meses
Puntos: 0
RTE Editor

Alguien del foro ha utilizado el RTE Editor? Tengo un problema cuando quiero levantar una variable cualquiera de php como valor predeterminado (en realidad es un valor de una bd).
Bueno, si alguien lo ha usado aqui posteo el código:

Código PHP:
<?php

if (!(isset($_POST["rte1"]))) {

        
$content $db_content/*aquí tengo el problema, si en ves de $db_content pongo un string cualquiera, el editor se carga, de esta manera no*/
        
$content rteSafe($content);
} else {
        
//retrieve posted value
        
$content rteSafe($_POST["rte1"]);
}

?>
//Usage: writeRichText(fieldname, html, width, height, buttons, readOnly)
writeRichText('rte1', '<?=$content;?>', 520, 200, true, false);


Si alguien sabe agradezco la ayuda
ratamaster
  #2 (permalink)  
Antiguo 07/03/2005, 12:55
O_O
 
Fecha de Ingreso: enero-2002
Ubicación: Santiago - Chile
Mensajes: 34.417
Antigüedad: 22 años, 3 meses
Puntos: 129
Según la sintax de uso .. en el 2° parámetro va el HTML que quieras usar .. Intenta no usar comillas simples sino dobles:

writeRichText('rte1', "<?=$content;?>", 520, 200, true, false);

Y prueba antes con un simple echo .. si tu $content tiene el valor esperado ..

Un saludo,
  #3 (permalink)  
Antiguo 07/03/2005, 13:38
 
Fecha de Ingreso: octubre-2004
Ubicación: En algún lugar de la República Oriental del Uruguay
Mensajes: 366
Antigüedad: 19 años, 6 meses
Puntos: 0
Es muy raro lo que me pasa con esto. Cuento:

tengo esta variable con el valor tomado de la bd (valor que le hice un echo y existe):

$db_content = $row2['description_english'];

luego uso este valor para darselo a la variable $content, entonces queda así:

Código PHP:
if (!(isset($_POST["rte1"]))) {

        $content = $db_content; // aquí uso el valor de la bd
        $content = rteSafe($content);
} else {
        //retrieve posted value
        $content = rteSafe($_POST["rte1"])."aaa";
}

?>//Usage: writeRichText(fieldname, html, width, height, buttons, readOnly)
writeRichText('rte1', "<?=$content;?>", 520, 200, true, false);
Ahora bien, esto no me funciona, pero si a la variable $db_content la defino de esta manera: $db_content = "ahora va a funcionar", cuando cargo el RTE, este si me muestra "ahora va a funcionar" !!!!

Enonces no entiendo porque no funciona con $row2['description_english'] y si con "ahora va a funcionar" a la hora de asignar el valor a la variable $db_content.

Si ayuda en algo, aquí decribo parte del escript:

Código PHP:
<?php
$db_content 
$row2['description_english'];
?>
<!--<form name="RTEDemo" action="<?=$_SERVER["PHP_SELF"]?>" method="post" onsubmit="return submitForm();"> //-->
<script language="JavaScript" type="text/javascript">
<!--
function submitForm() {
        //make sure hidden and iframe values are in sync before submitting form
        //to sync only 1 rte, use updateRTE(rte)
        //to sync all rtes, use updateRTEs
        updateRTE('rte1');
        //updateRTEs();

        //change the following line to true to submit form
        return true;
}

//Usage: initRTE(imagesPath, includesPath, cssFile, genXHTML)
initRTE("rte/images/", "", "", true);
//-->
</script>
<noscript><p><b>Javascript must be enabled to use this form.</b></p></noscript>

<script language="JavaScript" type="text/javascript">
<!--
<?php

if (!(isset($_POST["rte1"]))) {

        
$content $db_content;
        
$content rteSafe($content);
} else {
        
//retrieve posted value
        
$content rteSafe($_POST["rte1"])."aaa";
}

?>//Usage: writeRichText(fieldname, html, width, height, buttons, readOnly)
writeRichText('rte1', "<?=$content;?>", 520, 200, true, false);
//-->
</script>
</p>

<!--</form>//-->


<?php
function rteSafe($strText) {
//returns safe code for preloading in the RTE
$tmpString trim($strText);

//convert all types of single quotes
$tmpString str_replace(chr(145), chr(39), $tmpString);
$tmpString str_replace(chr(146), chr(39), $tmpString);
$tmpString str_replace("'""'"$tmpString);

//convert all types of double quotes
$tmpString str_replace(chr(147), chr(34), $tmpString);
$tmpString str_replace(chr(148), chr(34), $tmpString);
//   $tmpString = str_replace("\"", "\"", $tmpString);

//replace carriage returns & line feeds
$tmpString str_replace(chr(10), " "$tmpString);
$tmpString str_replace(chr(13), " "$tmpString);

return 
$tmpString;
}


ps: si hago esto: $db_content = print $row2['description_english'];
el RTE me carga "1", eso me es más extraño.
gracias
ratamaster
  #4 (permalink)  
Antiguo 07/03/2005, 14:19
 
Fecha de Ingreso: octubre-2004
Ubicación: En algún lugar de la República Oriental del Uruguay
Mensajes: 366
Antigüedad: 19 años, 6 meses
Puntos: 0
ok, me salió, agregé addslashes:

$content = addslashes($db_content);


gracias

ratamaster
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 09:39.