Jump to content
gebeer

CKEditor settings per template and/or role

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

Share this post


Link to post
Share on other sites

Hi all,

did I miss anything that might have happened in a few years in this context?

Share this post


Link to post
Share on other sites

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?

 

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
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

 

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • 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?
    • By Brian Peat
      Hello! I've got a single client on Processwire and it's completely foreign to me. I've been able to find most things, but they've asked for a custom designed page with a full width header image/section, and then a body block and a right side bar below the header. They're using a landing page template, so I duplicated that, figured out how to add it in the admin, and assigned it to the page. Nothing. It doesn't change a thing.
      I feel like I'm missing something obvious. I've made sure all the fields are the same, I tried to set up the parent/child stuff though this page doesn't have a parent that I can tell (though it's under Landing Pages). If I can get the template to actually kick in, I think I can use a bit of code to check for the hero section and load it at the top. I also made a copy of the widget template and set that to load instead of the original. But again, since my main page template isn't kicking in, neither is the new widget template.
      I'd just love some tips on what to check or change to get a landing page to actually render what's in the assigned page template.
      Hopefully I've used the correct terminology here to make sense.
      Thanks!
    • By rookie
      hi there,
      Is there a module or other solution to select a template with a preview image? Sometimes it is not that easy to describe a template.
      e.g. Template with 3 columns (image, title, content, button) or template for a slider with max. 4 pictures.
      Even if it is nice to have a description field for a template, a picture says more than thousand words could describe.
      And no, I don't think I could develop something like that. I don't even know where to start.🙄
×
×
  • Create New...