Jump to content

nurkka

Members
  • Posts

    130
  • Joined

Everything posted by nurkka

  1. As far as I know, there is no built-in way to do this. You would have to use a module or write one yourself. I found this post from ryan to be very helpful on that topic: https://processwire.com/talk/topic/1799-routes-and-rewriting-urls/#entry16754 In this thread you'll also find further information about rewriting urls. If you're rewriting urls there will certainly be side effects like the link module in ckeditor will not work properly anymore.
  2. You're right, it was the wrong hook. Now I'm using InputfieldCKEditor::processInput, but still don't get the right instance of MarkupHTMLPurifier. Next, I took a closer look at the code of InputfieldCKEditor.module and I tried to replace the hook method: public function ___processInput(WireInputData $input) { $value = trim($input[$this->name]); if($value == self::PLACEHOLDER_TEXT) return $this; // ignore value $value = $this->purifyValue($value); if($value != $this->attr('value')) { $this->trackChange('value'); $this->setAttribute('value', $value); } return $this; } The MarkupHTMLPurifier module is instantiated in the $this->purifyValue()-Method: if(is_null(self::$purifier)) self::$purifier = $this->wire('modules')->get('MarkupHTMLPurifier'); Is there any way to get self::$purifier from »outside«, i.e. from a hook method? If not, is it possible to replace the whole processInput-Method and call a custom instance of MarkupHTMLPurifier? I tried to do that, but it didn't work: public function hookMethod (HookEvent $event) { $this->message("Hook InputfieldCKEditor::processInput"); // the hook is called correctly $event->replace = true; // force replace the hook method $field = $event->object; $arguments = $event->arguments; // now I tried to adapt the code of the original method, but it didn't work. $value = trim($event->arguments[$field->name]); if($value == self::PLACEHOLDER_TEXT) return $field; $value = $field->purifyValue($value); if($value != $field->attr('value')) { $field->trackChange('value'); $field->setAttribute('value', $value); } return $field; } I think that must be possible, but how is it done correctly?
  3. Hi, the output of a CKEditor field is postprocessed by the MarkupHTMLPurifier module, which has no configuration settings in the backend. I want to tweak the html output, so I'm trying to change the MarkupHTMLPurifier settings. The easiest method would be, to change one line in MarkupHTMLPurifier.module, but I want to be save when updating ProcessWire. So I had the idea to change the module settings on runtime. To achieve that, I wrote following module: class configModifer extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'Config Modifier Test', 'version' => 1, 'summary' => 'This module tries to change the settings of another module on runtime.', 'singular' => true, 'autoload' => true, ); } public function init() { $this->addHookBefore('Inputfield::render', $this, 'beforeInputFieldRender'); } public function beforeInputFieldRender (HookEvent $event) { $purifier = wire()->modules->get('MarkupHTMLPurifier'); $purifier->set('HTML.Doctype', 'HTML 4.01 Transitional'); } } Unfortunately this doesn't work. The Hook is called, but it doesn't change the settings of MarkupHTMLPurifier. How can I change the module settings of MarkupHTMLPurifier on runtime? Or is there another way to achieve that? Thanks in advance.
  4. Thanks for your reply, LostKobrakai. I tried to put the plugin under /wire/, but that didn't work either. Then I renamed the plugin to »htmlwriter2« (located in /site/modules/InputfieldCKEditor/plugins/htmlwriter2/) and surprisingly that worked. I think there is a naming conflict with code in ckeditor.js. Perhaps, the plugin »htmlwriter« is already pre-installed or it has meanwhile been integrated in the CKEditor core. Nonetheless, I couldn't get it to work without installing it as »htmlwriter2«. Unfortunately, I also had no luck in configuring the plugin via the field settings of my »body«-Field. I tried the following JSON in the »htmlwriter2 settings«: {"selfClosingEnd": ">"} But that didn't work. I had to write this setting directly into the plugin file, but I would really like it better to be set via the backend. You asked, why someone would want to remove the trailing slashes of self closing tags – When I switched from XHTML to HTML5, I decided not to use trailing slashes anymore and I just wanted the HTML output to look equally, even if it comes from CKEditor. Next I will try to find out how the setting above can be set via the field settings in the ProcessWire backend.
  5. Hi, CKEditor generates <br /> instead of <br>, so I searched a method, to replace trailing slashes in self closing html tags. I found the CKEditor plugin Htmlwriter, which does just that, and installed it in /site/modules/InputfieldCKEditor/plugins/ in it's own subdirectory /htmlwriter/. Next I activated the plugin in my field configuration (field »body«) in the backend and added the required settings as JSON ({"selfClosingEnd": ">"}) to the now available »Htmlwriter settings« field. But that didn't work. So, I placed some debug code in Htmlwriter's plugin.js (console.log('plugin loaded') , but the message never showed up in the console. The same debug code in e.g. /wire/modules/Inputfield/InputfieldCKEditor/plugins/sourcedialog/plugin.js showed up perfectly. So, I assume the /site/modules/InputfieldCKEditor/plugins/htmlwriter/plugin.js isn't included at all, although it's configured in the field settings. I also get no error message, no 404s in the network panel or something like that. Additionally, if I try to set configuration settings in /site/modules/InputfieldCKEditor/config.js or /site/modules/InputfieldCKEditor/config-body.js they are ignored, while settings in the »Custom Config Options« field in the field settings work perfectly. Does anybody know what I am missing here? How is it possible to set up this CKEditor plugin properly in ProcessWire? Thanks in advance!
×
×
  • Create New...