Tema: RTE Editor
Ver Mensaje Individual
  #3 (permalink)  
Antiguo 07/03/2005, 13:38
ratamaster
 
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