Using redactor in front-end fails becaue of missing JS variable

Permalink
I've created a single page application where the users don't have edit access to anything, thus no toolbar on top.

This works fine, but adding a picture from the file manager fails because it is looking for the JS variable CCM_SECURITY_TOKEN which doens't exist in my case since page_controls_header.php isn't included.

Is there an official way to do this? I can easily hack this together but this thing should work for a bit more than a month..

Remo
 
Remo replied on at Permalink Reply
Remo
for any one who's into hacks, here's what one could add to the controller method:

$c = Page::getCurrentPage();
      if (is_object($c)) {
         $cp = new Permissions($c);
         if (is_object($cp)) {
            if (!$cp->canViewToolbar()) {
               $valt = Loader::helper('validation/token');
               $this->addHeaderItem('<script type="text/javascript">var CCM_SECURITY_TOKEN = \''.$valt->generate().'\';</script>');
            }
         }
      }


I still get two errors, one "$ is not defined" and another one "ccm_addHeaderItem is not defined" but the plugin works with this code..