Forums

Front end edit with jce editor

bjamieson 20 Feb, 2009
Hi,

I tried enabling front-end 'editing' of my form, it includes the following snippet:

<div class="form_element cf_textarea">
<label class="cf_label">Details</label>
<br/>
<?php echo $editor->display( 'Details',  '' , '100%', '350', '75', '20', false ) ; ?>
</div>


When front end editing is enabled, I get to see the rest of my form (it is basically a copy of the original chronoform), but the details textarea is empty... I think I'm missing some voodoo from that second parameter...

That is the method used to grab the editor and display the Details field to the user in the first instance. It works in the original 'Chronoform' but that just gives me 'front end doc creation' and 'back end doc editing'.

So it's just a little wierd...

1) The chronoform works to 'create' a new form (front end process).
2) In order to update the document the user needs to go via the back end.

Has anyone carried out subsequent edits on a textarea of a form with JCE as the editor ?

Thanks,

Brian
GreyHead 20 Feb, 2009
Hi Brian,

I don't remember what the second parameter is. My guess is that you need to 'require' an editor file for this to work . . . I'm pretty certain that it's been discussed before here. Have a search through the forums on 'editor'

Bob
Max_admin 20 Feb, 2009
try:

    <div class="form_element cf_textarea">
    <label class="cf_label">Details</label>
    <br/>
    <?php echo $editor->display( 'Details',  $row->Details , '100%', '350', '75', '20', false ) ; ?>
    </div>
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
bjamieson 26 Feb, 2009
Hi,
Sadly, I'm getting no joy trying to put the content of the 'Details' rich text field back into the editor.

Bob I looked for 'editor' and 'file', but no joy, sorry...

The $row->fieldname syntaxt, I think, is not what I need (?) since I figure that I'm 'at' the document level, and not at the 'list' level.

I have had to use $row-> within my php code elsewhere (the table rows section) since php and the field substitution syntax '{fieldname}' fight like kittens if you forget the following: You need to be careful how you make use of the field substitution, it happens AFTER the php code has been executed, right? And therefore the fieldname stuff has to be handled as text. If you want the php code to work depending on the value of a field, you need to dereference the field differently:
if( $row->img_dog_name =='nophoto'){

instead of
if( {img_dog_name} =='nophoto'){


My latest failed attempt:
<?php
$editor = & JFactory::getEditor();
$htmltext=$row->Details;
echo $editor->display( 'Details',  $htmltext , '100%', '350', '75', '20', false );
?>


Result on screen:
?
Details
Details; echo $editor->display( 'Details', $htmltext , '100%', '350', '75', '20', false ); ?>
?


Oh, I also tried:
$htmltext = JRequest::getString('Details', '', 'post');

But I'm pretty sure that's rubbish since I've not done a post yet 🤣

Now the really weird thing is that the syntax:
<?php echo $editor->display( 'Details',  '' , '100%', '350', '75', '20', false ) ; ?>


works sweet as a sweet thing when I use it in the 'Admin Config' tab, record edit template. And I don't need to be concerned with the second parameter...

Maybe THAT's the bug :wink:

Thanks for reading...
GreyHead 26 Feb, 2009
Hi Brian and Max,

There are some odd things here. I can get the editor to show up with the saved text using
<?php
$editor =& JFactory::getEditor();
echo $editor->display( 'text_1', '{text_1}', '100%', '200', '75', '10', false); 
?>
in the Record Edit Template [b]provided that is in the first <?php . . . ?> tags in the box/b]. If I try to put it further down then it does not display correctly.

I tried to echo the remaining html to get round this but any echo statements including the words 'name' or 'class' (and maybe others) generate PHP Parse errors.

Bob
bjamieson 26 Feb, 2009
Hi Bob,

You've nailed it !!! Well spotted.

I had a bit of code stashed at the top of my Record Edit Template (can't see a header section to put this stuff into) :
<script>
function removeSpaces(string) {
   document.adminForm.img_dog_name.value = filterSpecialChars(string.split(' ').join(''));
   return
}

function filterSpecialChars(str) {
   re = /\$|,|@|#|~|`|\%|\*|\^|\&|\(|\)|\+|\=|\[|\_|\]|\[|\}|\{|\;|\:|\'|\"|\<|\>|\?|\||\\|\!|\$|\./g;
   // remove special characters like "$" and "," etc...
   return str.replace(re, "");
}
function updateLastUpdated(){
document.forms['connectivity'].last_updated.value="<?php echo(date("Y\-m\-d \- G:i:s")); ?>";
}
updateLastUpdated();
</script>

So my last updated 'stamp' was the fragment of php that was stitching up the edit stuff.

As a workaround, I have dropped the code to the end of the template. Everything works correctly now - even my ropey updateLastUpdated() function.
Max_admin 26 Feb, 2009
Hi Bob and Brian,

Nice catch, I will track it down, will copy this to the bugs for now!

Regards
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.