Redactor in a Custom Block

Permalink 3 users found helpful
Does anyone have an example of how to include the redactor 'bar' within a custom block that they might be willing to share with me? That seems to be my next 5.7 hurdle.

Thanks in advance.
C

 
MrKDilkington replied on at Permalink Best Answer Reply
MrKDilkington
Hi Chrouglas,

I just figured it out this morning. Here is a quick run down.

in controller.php

public function add()
{
    $this->requireAsset('redactor');
    $this->requireAsset('core/file-manager');
}

public function edit()
{
    $this->requireAsset('redactor');
    $this->requireAsset('core/file-manager');
}

in your form
$fp = FilePermissions::getGlobal();
$tp = new TaskPermission();

<script>
    var CCM_EDITOR_SECURITY_TOKEN = "<?php   echo Loader::helper('validation/token')->generate('editor')?>";
    $('#redactor-content').redactor({
            minHeight: '130',
            'concrete5': {
                filemanager: <?php   echo $fp->canAccessFileManager()?>,
                sitemap: <?php   echo $tp->canAccessSitemap()?>,
                lightbox: true
            },
            'plugins': [
                'fontfamily','fontsize','fontcolor','concrete5'
            ]
        });
</script>

<div class="form-group">
   <?php  echo $form->label('content', t('Content:'));?>
    <textarea style="display: none" id="redactor-content" name="content"><?php echo $content?></textarea>
</div>

in view.php
<div>
   <?php echo $content; ?>
</div>

in db.xml
<field name="content" type="X2"></field>
Chrouglas replied on at Permalink Reply
Thats awesome. Ill give it a try. Thank you, C

I think I was missing the public functions add() and edit()... oops.
dclmedia replied on at Permalink Reply
dclmedia
Awesome MrKDilkington! Thank you!
dclmedia replied on at Permalink Reply
dclmedia
This is great, and I have got it working on the main site, but I am trying to configure a dashboard form that will require Redactor. I have following the same instructions but cannot get it to work on my Dashboard Single Page form.

Any suggestions?
MrKDilkington replied on at Permalink Reply
MrKDilkington
That is a good question.

I don't have any example packages that use Redactor in a dashboard single page.
dclmedia replied on at Permalink Reply
dclmedia
I have found the solution to this...

I placed the jquery for the redactor inside the following and it works ok.

(function($) {
    $(document).ready(function () {
...
...
    });
})(jQuery);


On to the next issue...
dclmedia replied on at Permalink Reply
dclmedia
This is great, and I have got it working on the main site, but I am trying to configure a dashboard form that will require Redactor. I have following the same instructions but cannot get it to work.

Any suggestions?
dclmedia replied on at Permalink Reply
dclmedia
This is great, and I have got it working on the main site, but I am trying to configure a dashboard form that will require Redactor. I have following the same instructions but cannot get it to work.

Any suggestions?
dclmedia replied on at Permalink Reply
dclmedia
This is great, and I have got it working on the main site, but I am trying to configure a dashboard form that will require Redactor. I have following the same instructions but cannot get it to work.

Any suggestions?