Flask-CKEditor - Error code: editor-element-conflict - flask

In my flask app, I have 2 instances of CKEditor on 2 different files.
<div>
{{ ckeditor.create(name="message_body") }}
{{ ckeditor.load(pkg_type="standard") }}
{{ ckeditor.config(name="message_body", width=1000, height=500) }}
</div>
and
<div>
{{ ckeditor.create(name="newsletter_body") }}
{{ ckeditor.load(pkg_type="standard") }}
{{ ckeditor.config(name="newsletter_body", width=1000, height=500) }}
</div>
Each of those <div> are in a {% block main %}
I'm getting the data from from 2 different file with these lines:
request.form.get("message_body")
and
request.form.get("newsletter_body")
All seems fine, I get the data but in my browser I get this errors:
[CKEDITOR] Error code: editor-element-conflict.
Object { editorName: "message_body" }
The related docs read this:
Description: There is already an editor’s instance attached to the provided element and attaching another one to it is not allowed.
Additional data:
editorName: The name of the already attached editor.
But I don't understand why. Can any one help me get rid of these errors?
Many thanks

I just release 0.4.5 to fix this, please upgrade:
pip install -U flask-ckeditor
The reason behind this error is:
When you add a "ckeditor" class to a textarea element, CKEditor will try to initialize a CKEditor editor box on top of it. At the same time, if you initialize a CKEditor editor box manually with CKEDITOR.replace(...) (which is what the ckeditor.config() does), the error happens: you can't initialize two CKEditor editor box on one textarea element.

Related

How do I get data from a query datasource field in Sitecore using Scriban?

I have a query datasource field, and I want to access the data from within that field.
I have tried things like:
{{ for i_data in (sc_query i_page 'query:{{ i_page.NameOfField }}') }}
<h1>{{ i_data.Title }}</h1>
{{end}}
and
<h1>{{ i_data.NameOfField.Title }}</h1>
For the first example, I have also tried 'query:'{{ i_page.NameOfField }}. I have copied and pasted the query to make sure it is valid, and it is. It works. Am I getting some syntax wrong, or is there another way of doing this?

Drupal 8 Theme CSS not attached

I have the following theme configuration ...
mytheme.info.yml
name: MyTheme
type: theme
description: Theme based on Emulsify.
base theme: stable
core: 8.x
# Libraries (These are loaded on every page. Use https://www.drupal.org/developing/api/8/assets#twig whenever possible.)
libraries:
- mytheme/global
mytheme.libraries.yml
global:
version: VERSION
css:
theme:
dist/style.css: {}
That stylesheet is not being attached to my pages. I tried adding the same stylesheet onto the Bartik theme in the same way and it worked fine. Any thoughts on what I'm missing or how to track this down?
Thanks!
EDIT:
I'm getting "Notice: Array to string conversion ... " I believe on this line that gets generated in the file "sites\default\files\php\twig\5c785ff00bd6e__html.twig_0yYIGbLfvl1AKm7qslTBE8W-Z\Fay9SGEvR_arQ_YULxnlOBW1yidhbxKLSR3KrUE5-bc.php":
echo $this->env->getExtension('Twig_Extension_Sandbox')->ensureToStringAllowed($this->env->getExtension('Drupal\Core\Template\TwigExtension')->escapeFilter($this->env, ($context["page_top"] ?? null), "html", null, true));
My _html.twig file:
<!DOCTYPE html>
<html{{ html_attributes }}>
<head>
<head-placeholder token="{{ placeholder_token|raw }}">
<title>{{ head_title|safe_join(' | ') }}</title>
<css-placeholder token="{{ placeholder_token|raw }}">
<js-placeholder token="{{ placeholder_token|raw }}">
</head>
<body{{ attributes }}>
<a href="#main-content" class="visually-hidden focusable">
{{ 'Skip to main content'|t }}
</a>
{{ page_top }}
{{ page }}
{{ page_bottom }}
<js-bottom-placeholder token="{{ placeholder_token|raw }}">
</body>
</html>
I had started my theme on another, clean install of Drupal 8 and then moved it over to my working installation. I didn't even think about the fact that I already had a module in that install that had the same name as my theme. Rename the theme, problem fixed.
Leaving this here as a warning to others - do not use the same name for a theme and a module. Should probably be obvious, but maybe you end up here anyway like I did.

Django bootstrapform render field and lable separate in template

I am using Django 2.0.4 with bootstrapform https://github.com/tzangms/django-bootstrap-form . I would like to render my field and label separately in my template.
Currently I can render the field using:
{% load bootstrap %}
{{ form.fieldname|bootstrap }}
I would to find a way to separate the render of the label from the field so that I can insert text next to the label for selecting tool-tip. Is anyone able to point me in the right direction to achieve this? Any help will be much appreciated!
Try the following : This link provides more info
{{ form.field_name }} will render the field
{{ form.field_name.label }} will render the label
{{ form.field_name.id_for_label }} the ID

How to get form fields' id in Django

Is there any way to get the id of a field in a template?
In the HTML I get: <input name="field_name" id="id_field_name"...
I know I can get the name with {{ field.html_name }}, but is there anything similar for getting the id?
Or can I only get it like this: id_{{ field.html_name }}?
You can get the ID like this:
{{ field.auto_id }}
You can also use id_for_label:
{{ field.id_for_label }}
This doesn't work for every form field.
For instance {{ form.address.auto_id }} works while {{ form.address.auto_name }} will not.
However you can use {{ form.address.html_name }} to get the equivalent answer.
Here are the docs
From the documentation-
each form field has an ID attribute set to id_<field-name>
, which is referenced by the accompanying label tag. This is important in ensuring that forms are accessible to assistive technology such as screen reader software. You can also customize the way in which labels and ids are generated.
So I would like to say id_field-name , you collect the field name from the model.
Here is the link to the documentation
In Django 2 you can retrieve the ID for a specific field using {{ field.id_for_label }}
This is documented here.

Django: Photologue does not show images in templates

I am trying to install django-photologue. Everything seems ok, because I install and set up following the official guidelines. I have to upload some photos as examples. However, when viewing a photo or gallery details , then an error as follows:
Caught an exception while rendering: 'Photo' object has no attribute 'get_thumbnail_url'
I tried to remove the following code from the file photo_detail.html
{% if object.public_galleries %}
<h2>This photo is found in the following galleries:</h2>
<ol>
{% for gallery in object.public_galleries %}
<li>{%previous_in_gallery object gallery%} {{ gallery.title }} {%next_in_gallery object gallery%}</li>
{% endfor %}
</ol>
{% endif %}
No more errors, but pictures do not show up. If you click on the link will still lead to correct photographs to see. I think the problem in:
{{ object.get_display_url }}
It is totally not return any value.
Please help me solve this problem. Thanks!
Did you run python manage.py plinit after install and opt to create both a thumbnail and display photosize? These photosizes need to be defined in your database.
In other versions, you have to edit photologue/templates/photolog/tags/next_in_gallery.html and replace
{{ photo.get_thumbnail_url }}
with
{{ photo.thumbnail.url }}
Same for photologue/templates/photolog/tags/prev_in_gallery.html.
Honestly from looking at the source, it looks like a bug in the project. If you search the source, thumbnail doesn't seem to be a field within the Photo class (get_FIELD_url is an easy way to access an ImageField's url btw.) So I would recommend tinkering with the source or finding another project. I might be wrong though but that's what my ~5 minute scan of the project found.