Christophe Posted June 8, 2015 Posted June 8, 2015 Hello, How can we allow an id in CKEditor? *(class) works for classes. *[id] should work for ids normally, but apparently it doesn't. I have already had this problem before, and have tried to find an answer, the only difference being that this time I'm posting a message.
cstevensjr Posted June 8, 2015 Posted June 8, 2015 How are you trying to use the ID in CKEditor? I ask because if it's related to linking an image I can help you out.
Christophe Posted June 8, 2015 Author Posted June 8, 2015 Hello cstevensjr, For some websites, I would like to be able to allow an id. For example, I have to use class="credit" because I can't use id="credit" apparently. But an id would be more appropriate in this case, and in other cases as well. It's related to (the) styling (of) a paragraph containing a link to my website. The information is in a hidden "footer" page. I've tried replacing *(credit) for the class with *[credit] for the id. Admin >Setup >Fields > Edit Field: body -> Input -> Extra Allowed Content: *(centre)*(gras)*(noir)*(credit)
LostKobrakai Posted June 8, 2015 Posted June 8, 2015 I don't know if you read the documentation for "Allowed Content Rules", but there it states that [] are for attributes, {} for styles and () for classes. Therefore you need to use *[id] to allow id's. You can only allow/disallow specific contents for the style and class attribute. All the other attributes (including id) are either allowed in any form or not. Edit: Your version would allow for this: <a centre="something" gras="green" noir="dark" credit="given">I'm a link</a> 4
Christophe Posted June 8, 2015 Author Posted June 8, 2015 Hi, In this case, in a production website: *(centre) is active with class="centre"*(gras) is active with class="gras" <- bold*(noir) is active with class="noir" <- black*(credit) is active with class="credit" I would just like to be able to allow id="credit" instead of a class. As I've said, I've tried to use *[credit]. It doesn't seem to be the way to do it (perhaps just by default in ProcessWire).
LostKobrakai Posted June 8, 2015 Posted June 8, 2015 I think you didn't understand what I tried to describe. HTML attributes are two parts: attribute="value". You can only allow predefined values for classes and styles ( with () and {}). You cannot do that for other attributes, like in your case id. You can only allow the whole attribute without restricting the value. *[id] (id in literally these two characters, not as replacement) does allow id's for any element and any actual id value. Kinda like this: <* id="*"></*> 1
titanium Posted June 9, 2015 Posted June 9, 2015 All the other attributes (including id) are either allowed in any form or not. I would like to add that this is true for allowed content rules in string format. If object definitions are used, there are more possibilities. For example, a function can be called which allows only a match of certain values for id.
Christophe Posted June 9, 2015 Author Posted June 9, 2015 In fact, I had understood at first. But then I had thought that I hadn't understood with: "Edit: Your version would allow for this: <a centre="something" gras="green" noir="dark" credit="given">I'm a link</a>" I had read (more than once perhaps) the following part too quickly: "// Rules allowing:// * <p> and <h1> elements with an optional "id" attribute,// * <a> with a required "href" attribute and an optional "id" attribute.p h1; a[!href]; *[id]" I wanted to only allow one id, not all (via the backend). So it's probably why I haven't tried the *[id].Apparently it's not possible. Edit: at least this time, I will just insert the part of the code with the id in the appropriate template file.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now