WYSIWYG in Block: Add works - Edit doesn't

Permalink
Hey folks!
I've got a quick question!

While my block works perfectly well when adding, it does not restore the entered data when editing?

add.php:
<?php 
defined('C5_EXECUTE') or die("Access Denied.");
$bt->inc('editor_init.php');
echo $form->label('hdl', 'Headline');
echo $form->text('hdl', array('style' => 'width: 320px'));
?>
<textarea id="ccm-content-<?php echo $a->getAreaID()?>" class="advancedEditor ccm-advanced-editor" name="content" style="width: 580px; height: 380px">
</textarea>


edit.php:
<?php 
defined('C5_EXECUTE') or die("Access Denied.");
$bt->inc('editor_init.php');
echo $form->label('hdl', 'Headline');
echo $form->text('hdl', array('style' => 'width: 320px'));
?>
<textarea id="ccm-content-<?php echo $a->getAreaID()?>" class="advancedEditor ccm-advanced-editor" name="content" style="width: 580px; height: 380px">
</textarea>


What might be wrong with edit.php?

Thanks! <3

SlapY
View Replies: View Best Answer
firepixel replied on at Permalink Best Answer Reply
firepixel
Hi there

You are missing the second parameter to the 'text' function, try this: -

echo $form->text('hdl', $hdl, array('style' => 'width: 320px'));
SlapY replied on at Permalink Reply
SlapY
Oh yeah right! That fixes HDL thanks!

But the WYSIWYG is still not restoring?
SlapY replied on at Permalink Reply
SlapY
Okay, was missing
<?php echo $content; ?>
inside of the text area.

DONE
firepixel replied on at Permalink Reply
firepixel
If you are doing what I think you're doing (attempting to get a WYSIWYG editor inside of a edit block form) you are going to run into much bigger problems. You need to implement controller methods to translate the content into a format that will go in the database.

Give me a shout if you want the code, have done this many times!
SlapY replied on at Permalink Reply
SlapY
Yes - i'm trying to use the WYSIWYG Editor inside of my block.

I copied the code from an original Concrete5-Block and had no problems using the editor so far.

Why should the database be concerned about the HTML-Code the WYSIWYG is generating? Text is text right?

I'm going to check the original db.xml to see if the fields differe from mine.

Thanks!
SlapY replied on at Permalink Reply
SlapY
It uses
<field name="content" type="X2"></field>


just like I do?
firepixel replied on at Permalink Reply
firepixel
Yes if you are just using one entry and you have copied the core content block then that should be fine.

It matters because if you have quotes in your content (like you will in a link) then this messes up the SQL and tends to truncate your content.

In the edit.php and add.php you will have to use
<?php echo $controller->getContentEditMode()?>

to call the function that translates it, and make sure you have copied the contents of controller.php from the content block. That's assuming you are using the additional buttons for integrating with the file manager and sitemap.
firepixel replied on at Permalink Reply
firepixel
I don't mean one entry, but if you are doing everything in one database table it's much easier. Wrote a block that uses a tool to update it in AJAX, very messy.
SlapY replied on at Permalink Reply
SlapY
Alright ... I looked at the original controler.php and noticed the function you meant (and understood why the function was missing in the first place)

Tho', I'm experiencing no problems using links inside the WYSIWYG and I'm also able to edit the block after using links inside of it.

No problems here :)
chameleondesign replied on at Permalink Reply
chameleondesign
Hi are you able to post the code for multiple wysiwyg fields inside edit block?
firepixel replied on at Permalink Reply
firepixel
Shouldn't be any different, do you want to elaborate and post your current code?
chameleondesign replied on at Permalink Reply 1 Attachment
chameleondesign
Hi Forgot to monitor post - I am now.
Yeah - basically I am adapting the power slider light addon by Michael G to have wysiwyg on the input fields. This is because I have varying font styles on slider. (website is dogtiredinkent.co.uk) But It usually chokes and only renders one out of mulitple fields as a wysiwyg as these are dynamically added and sorted.

It also freezes when adding the slides. Maybe it is something to do with ids on the initialisation of tiny MCE?
<div style="margin: 10px 0;">
            <?php  echo $form->label('powerSlidePhraseTitle[]', 'Caption');?>
               <?php  echo $form->textarea('powerSlidePhraseTitle[]', $imgInfo['powerSlidePhraseTitle']."", array('class'=>'advancedEditor ccm-advanced-editor' ));?>
         </div>
         <div style="margin: 10px 0;">
         <?php  echo $form->label('powerSlidePhraseDesc[]', 'Price flash');?>
                 <?php  echo $form->textarea('powerSlidePhraseDesc[]', $imgInfo['powerSlidePhraseDesc']."", array('class'=>'advancedEditor ccm-advanced-editor'));?>
         </div>
.
firepixel replied on at Permalink Reply
firepixel
OK I think I follow.

Have you tried taking the code from editor_init and using it to initialise them one at a time as you load them? You would need to give them a unique id and use this instead of the class as the jQuery selector.
chameleondesign replied on at Permalink Reply
chameleondesign
I will look into it - doesn't sound easy though. Thanks.
firepixel replied on at Permalink Reply
firepixel
Actually it should work the way you have coded it, what have you got the Rich Text Editor mode set to in c5?

Have you checked for javascript errors in the browser?