Jump to content

CKEditor settings per template and/or role


gebeer
 Share

Recommended Posts

It would be fantastic if we could set different configurations for CKEditor fields based on template or user roles.

Like described on https://weekly.pw/issue/14/ under "More CKEditor upgrades", we can use config files in /site/modules/InputfieldCKEditor/ to store settings per field. E.g. for the body field this would be

/site/modules/InputfieldCKEditor/config-body.js.

Maybe this logic could be extended to something like

/site/modules/InputfieldCKEditor/config--field-body--template-home--role-mycustomrole.js.

I was coming over from Joomla to PW couple of years ago and there we had an excellent CKEditor integration called JCE where you could define settings per user role etc.

Maybe I am wrong but up to now we need to create additional fields if we need editor config settings per template. If there already is a way to do that I'd be happy to know. 

  • Like 7
Link to comment
Share on other sites

  • 4 years later...
  • 2 months later...
On 10/19/2020 at 10:26 AM, modifiedcontent said:

Is CKeditor now part of Processwire? I use CKeditor in a template, but using a version I downloaded in a template js folder. What is the correct way to use CKeditor in a template, on the front-end?

 

You can load all the CKEditor assets in a template by loading the module

$modules->get('InputfieldCKEditor');

This will load all assets to $config->scripts and $config->styles
Now in your main.php (or template file that renders your <head>) you need to include something like

foreach ($config->styles as $file) echo "\n\t<link type='text/css' href='$file' rel='stylesheet' />\n";
foreach ($config->scripts as $file) echo "\n\t<script src='$file'></script>\n";

This approach is only working with the delayed output strategy.

  • Like 1
Link to comment
Share on other sites

On 11/1/2020 at 7:54 PM, modifiedcontent said:

Did you find solutions for your original question from 2016, CKEditor settings per template and/or role? I'll have to figure that out next and will post here what I find out.

Here is one possible way to go about this:

  1. add the user role and template name to the ProcessWire.config JS object with https://processwire.com/api/ref/config/js/
  2. in /site/modules/InputfieldCKEditor/config.js retrieve that information and setup different CKEditor configs depending on role/template

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Similar Content

    • By nabo
      Hello
      it would be nice if it could be possible to force a unique (or relative) imagefield for CKEditor.
      Example
      Using a repeater matrix (or repeater) with CKEditor field, the primary sources for images are imagefields in the page-repeater fieldset. Obviously I can change the page source, but I need to start from the root and this is not comfortable. In this specific situation the better solution is to have an imagefield in the parent page and force CKEditor to automatically go there... or if you want to have a "media library" go there first.
      Don't know which could be the best "setting system" but in my opinion this is an annoying problem.
    • By franciccio-ITALIANO
      Hi everyone.
      I've created 12 templates that are the same but each with an extra bit of html code. 
      The piece of code is as follows:
      <div> <div class="box-pf"> <i class="fa fa-map-pin fa-2x fa-red faa-pulse animated"></i> <a href=""> <span class="uk-text-middle"><i>Sonchus oleraceus</i> 'Grespino degli Orti'</span></b> </a> </div> </div> On the third line we read "fa-red."
      I created 12 similar templates.
      The first template has only one box with fa-red, the last template has 12 boxes with icons of 12 different colors.
      So. is there any way to have only 1 template and add, if I want and when I want, a small or big, same or different piece of html code?
       
    • By fruid
      inserting links i.e. <a>-elements, and only links, inside a CKEditor-summary field outputs the link-text and a weird " /> above the content-div (I'm using markup regions).
      I have no idea where this is coming from, all the other tags work perfectly, and the CKEditor-markup is fine too when adding links. It puts the <a>-element inside a <p> element but should be alright?
      Any hints?
    • By fruid
      I doubt nobody has seen this issue before…
      when I have an <h2> or <h3> or the likes in a CKEditor-body-field and I delete that header, the h-tag is applied to whatever comes next in line. I'm obviously talking about the WYSIWYG-view. Similar bugs occur when applying an h-tag, that tag sometimes encloses the next line as well. Could be that this happens when the next line is in the same "block"-element and not technically a new line but separated with a <br> but not always…
      When will a new version of CKEditor for PW be released or what's a competitive alternative at this point?
×
×
  • Create New...