Theme developer module crashes the whole site when enabled, how to fix?

3 days 19 hours ago

I'm working on a clean Drupal 7.x installation, downloaded Theme developer and its dependent module simplehtmldom API( another required module for Theme developer) using drush.

I found out that simplehtmldom 7.x-2.x is incompatible; so I removed it, and Installed the 7.x-1.12 version using Drush, enabled it, enabled the Theme developer module was available to be enabled. Now the site doesn't work anymore.

All I'm seeing is just some tags like this.

< /> < /> < /> < /> < /> < /> < /> < /> < /> < />

The problem is fixed when I disable the Theme developer module manually with Drush; everything gets back to normal, when I disabled that module.

I've tried to navigate the site using /node/1 and tried to go to the administration panel; all I noticed is that the title of the page (the one appearing on the browser's tab) appears but the content seems to be the same.

How do I solve this issue?

This is a screenshot.

Kareem

How can I modify CKEditor 5's CSS variables?

3 days 19 hours ago

Although Drupal is designed to be styled using css files and configuration in the *.libraries.yml files, the CKEditor 5 module defines some styles in a Java Script file which:

  • Is included at the end of the page in Drupal so it overrides all styles defined in css files which are included in header.
  • Uses css variables to define various properties for styling purposes.

These variables are supposed to be modified as described in the CKEditor 5 Theme customization documentation. However, when a css file with custom values is included in Drupal, it's placed in the header which means the js overrides the custom values and not vice-versa.

So, the question is: as the CKEditor 5 is part of the Drupal core, what's the proper Drupal-way to override its css variables to customize the editor? Is there a Drupal documentation addressing this which I missed?

Example

The JS defines following style for the background of edited CKE field:

.ck.ck-editor__main>.ck-editor__editable { background: var(--ck-color-base-background); border-radius: 0; }

So in order to change the background, the --ck-color-base-background variable should be modified.

What I Tried

Created the css/components/ckeditor.css file:

:root { --ck-color-base-background: green; }

This attempts to modify the variable as described in the CKEditor 5 Theme customization documentation.

#app .ck-content { --ck-color-base-background: red; }

This attempts to modify the variable a way I found on some page, regrettably lost the link and cannot find it again.

.ck.ck-editor__main > .ck-editor__editable { background: blue; }

And this attempts to override the style directly.

Attempt #1

Include the custom css file in the my_theme.info.yml file as described in New API for adding theme-specific styles in CKEditor 5 and How to style custom content in CKEditor 5 Drupal documents:

ckeditor5-stylesheets: - css/components/ckeditor.css

Result:

  • The file is included in the middle of header.
  • The variable is unchanged and the custom style is overridden by default CKEditor style (from the CKE js.)
Attempt #2

Increase weight of the css file in the my_theme.info.yml file:

ckeditor5-stylesheets: - css/components/ckeditor.css: { weight: 100000 }

Result:

  • Failed with PHP error TypeError: strpos(): Argument #1 ($haystack) must be of type string, array given in strpos() (line 257 of core/lib/Drupal/Component/Utility/UrlHelper.php).
Attempt #3

Extend the core/ckeditor5 library.

In my_theme.info.yml file:

libraries-extend: core/ckeditor5: - my_theme/ckeditor5

In the my_theme.libraries.yml file:

ckeditor5: css: component: css/components/ckeditor.css: { weight: 100000 }

Result:

  • The custom css file is included last in the header.
  • The variable is unchanged and the custom style is overridden by default CKEditor style (from the CKE js.)
Attempt #4

The CKEditor 5 Theme customization documentation says that the css file can be imported in Java Script.

In the my_theme.libraries.yml file:

ckeditor5: css: component: css/components/ckeditor.css: { weight: 100000 } js: js/components/ckeditor.js: { attributes: { type: module } }

The custom ckeditor.js file:

/** * @module my_theme/ckeditor */ import '../../css/components/ckeditor.css';

Result:

  • The js file is included after the core/ckeditor5 libraries.
  • The js file fails with the Loading module from “.../css/components/ckeditor.css” was blocked because of a disallowed MIME type (“text/css”) error.
Attempt #5

In the Adding assets (CSS, JS) to a Drupal theme via *.libraries.yml Drupal documentation, there's mentioned header property. It's meant for Java Script, but let's try whether it works also for CSS.

In the my_theme.libraries.yml file:

ckeditor5: header: false css: component: css/components/ckeditor.css: { weight: 100000 } js: js/components/ckeditor.js: { attributes: { type: module } }

Result:

  • The custom css file is still in header.
Attempt #6

An answer to the How to make CSS and JS both load in the footer question mentions scope option.

In the my_theme.libraries.yml file:

ckeditor5: header: false css: component: css/components/ckeditor.css: { weight: 50, scope: footer }

Result:

  • The custom css file is still in header.
Technical Details

The style with variables I mentioned above is defined in the core/assets/vendor/ckeditor5/ckeditor5-dll/ckeditor5-dll.js file. It's already minified, so it's hard to read and figure out how it works, but it's the only place found by text search which sets it.

Other Links
  • CKEditor 5 background-color ignored in Olivero subtheme? Drupal issue - related to this, closed as "works as designed," but doesn't provide actual solution to changing CKE css variables, it just suggests:
    1. To use different, more specific css selector. This goes against the CKE documentation and doesn't answer to how generally modify these variables. Also, this is prone to errors as variables can be used by multiple styles, so one needs to be really careful to override them all.
    2. To override the relevant library. Are we really supposed to provide custom version of the ckeditor5-dll.js file?
    3. Move styles down with weight. As demonstrated above, this cannot work unless there's a way to move it between js files in the footer.
  • how can I style ckeditor5?( background-color and stuff ) question - basically same problem, but outside Drupal. The answer is to override the --ck-color-base-background which is what I'm trying to do, but can't figure how to do that in Drupal.
  • New API for adding theme-specific styles in CKEditor 5 Drupal page - at the end, there's a question asking similar thing, ignored.
Notes
  • I use updated Drupal 10 (via PHP Composer if that matters.)
  • During testing, I disabled merging css/js files.
  • After each attempt, I cleared cache and confirmed that the css/js file are actually included.
Tom

Display a key from unserialized data field

3 days 20 hours ago

I really don't understand how the "User: Data" field works. Couldn't find any documentation of this.

I want to set the Display format to "A certain key" to output the identifier value from this serialized data (relevant snippet):

a:1:{s:10:"hybridauth";a:26:{s:10:"identifier";s:17:"76561198181833179";

When I enter identifier as key, I only get this notice and no output.

Notice: Undefined index: identifier in views_handler_field_serialized->render() (line 60 of www/htdocs/****/sites/all/modules/views/handlers/views_handler_field_serialized.inc).

What do I have to enter in the "Which key should be displayed" field exactly, to display the identifier value?

Oddy

How to read JSON data from external URL and display it in a node

3 days 21 hours ago

I want to read json data from external url and display those data in a node. After that I would like to add filters in the result using views. I have created a view using external url(query settings) and display result in a block.. But I cant add filters for that. How to add Filters for that data.. I am new to this.. Please help me..

user59887

Custom field "required" validation

3 days 22 hours ago

I built a custom field type using the Field API. In hook_field_validate I have some logic to validate some very custom stuff, but when I tried to add a "This field is required" validation, I realized this hook runs on the from that you fill when you're adding a field to an entity. Then, I implemented hook_field_is_empty, which I know runs when the entity saves. Problem is, even if the hook runs and the field is empty, no validation occurs (i.e. the user doesn't get the "this is required" message, and the form submits).

So, what's the right way to do a "this field is required" validation?

cambraca

Programatically change exposed filter value based on another exposed filter

3 days 23 hours ago

I have 2 exposed filters in my Drupal 8 view - both are select dropdowns. I want the value of the 2nd filter to change based on selection of first filter Here are the filters $filters = $view->display_handler->getOption('filters');

$filters['country'] and $filters['states'].

Problem is that I always get an empty value when I try to access country filter in my views_pre_view hook.

dpm($filters['country']['value']) always prints empty.

How do I solve this please?

ilechcod

How to convert gif to webm?

4 days 2 hours ago

How I can convert gif (animation images) to webm? I'm add webm format to ImageMagic but after create image style with convert to webm I have error:

ImageMagick error 1: convert-im6.q16: delegate failed `'ffmpeg' -nostdin -v -1 -i '%M%%d.pam' -plays %I '%u.%m' 2> '%u'' @ error/delegate.c/InvokeDelegate/1966. [command: convert [convert] [core/modules/image/sample.png] [-quality] [95] [WEBM:/var/www/html/web/sites/default/files/styles/w700gif/public/core/modules/image/sample.png.webm]]

Aleksandr

How to set a default value for Simple hierarchical select?

4 days 2 hours ago

I tried to implement hook_form_alter in order to pass default value to Simple hierarhical select views exposed filter.

function mymodule_form_alter(&$form, &$form_state, $form_id) { $tid = get_tid_from_termalias (arg(1)); // here I get tid $form_state['input']['field_sity1_tid'] = (!empty($tid)) ? $tid : 'All'; $form_state['field_sity1_tid']['#value'] = (!empty($tid)) ? $tid : 'All'; $form['field_sity1_tid']['#default_value'] = (!empty($tid)) ? $tid : 'All'; $form['field_sity1_tid']['#value'] = (!empty($tid)) ? $tid : 'All'; }

I see that shs.js creates 2 selects, one hidden and one shown. My code changes only the value in the hidden select while second select always remains 'All'. How to change the visible select's default value?

Yuriy Kosyanchuk

Some tokens show as "missing name or description" in status report

4 days 3 hours ago

Looking at a Drupal 7.43 maintenance project, my status report lists the following issue for Token 7.x-1.6:

The following tokens or token types are missing required name and/or description information: $info['types']['date'] $info['tokens']['node']['url'] $info['tokens']['file']['size'] $info['tokens']['user']['url'] $info['tokens']['date']['custom'] The following token types are not defined but have tokens: $info['types']['node'] $info['types']['term'] $info['types']['vocabulary'] $info['types']['file'] $info['types']['user'] $info['types']['current-user']

I have cleared cache a few times, hit update.php, and ran cron a handful of times. This message never goes away.

It is causing RealName to no longer work, path aliases are not being made, and page title / meta tags are not appearing (all are driven by Token).

What is causing this and how can I fix it? I am unable to replicate the issue locally with the same database and same code.

Kevin

Get content types field in another content type with the entity reference relationship

4 days 4 hours ago

I have two content types. Person and Projects. I use a entity reference for the persons name on the project node so people can select the person that is involved in the project. Now using that reference I also want to get another field from the persons content type, and display this. I can't figure out how to do this. I thought I could do it with a views. I created a view with a relationship and filter with NID but it just doesn't seem to work. Whats the simplest way (view or not) to do this?

karl

How do you programmatically create a webform with a managed_file type?

4 days 5 hours ago

I haven't been able to find a single example of how to create a webform with a managed_file type.

The webform initially had the type 'file', but needs to be changed to accept multiple attachments. When the type is changed to 'managed_file', the field for uploading attachments does not render.

Here is my code snippet for the attachment field:

7 => array( 'name' => t('Attachment'), 'form_key' => 'attachment', 'type' => 'managed_file', 'upload_location' => NULL, 'pid' => 1, 'weight' => 6, 'value' => '', 'required' => '0', 'extra' => array( 'directory' => 'story', 'title_display' => 'before', 'private' => 0, 'wrapper_classes' => '', 'css_classes' => '', 'filtering' => array( 'size' => '2 MB', 'types' => array( 'gif', 'jpg', 'jpeg', 'png', 'txt', 'rtf', 'html', 'pdf', 'doc', 'docx', 'ppt', 'pptx', 'xls', 'xlsx', 'zip', ), 'addextensions' => '', ), 'rename' => '', 'scheme' => 'public', 'progress_indicator' => 'throbber', 'description' => '', 'attributes' => array(), 'analysis' => FALSE, ), ), );

Thanks much!

Anne

Install without Bootstrap CDN

4 days 6 hours ago

I have the theme Bootstrap CDN 3.3.6 installed on my site and I use the appearance "Journal". How not to use the CDN maintaining the appearance "Journal" ? Thank you

  • I download on Bootstrap http://getbootstrap.com/getting-started/#download and I copy the folder in my sub-theme, as you can see on the screenshot.
  • I copy the file overrides-journal.min.css to bootstrap theme of css file my subtheme.
  • I added a few lines in my file bootstrap_subtheme_front_office.info, see the catch.
  • I disabled CDN in subtheme /admin/appearance/settings/bootstrap_subtheme_front_office
  • I deleted the cache.

If I erases the line stylesheets[all][] = css/overrides-journal.min.css the theme works correctly but I want to show the appearance of the theme "Journal".

If I add the line stylesheets[all][] = css/overrides-journal.min.css the theme "Journal" is not applied.

user54067

How to acess API rest/views using token or login?

4 days 7 hours ago

I have a Drupal 8 website. I need to access the list of articles using www.myexample.com/rest/views/articles.

I could get the token using curl --header "Content-type: application/json" -b cookies.tt --request POST "https://www.myexample.com/user/login?_format=json" --data '{"name":"myname", "pass":"mypassword"}'.

How do I use cUrl to pass the token or user/pass and get 'rest/views/articles' in JSON format?

I tried curl --header 'authorization: Bearer {D12G7AajU9NdUAb260zqwCimfdddR1Krg5}' --url https://www.myexample/rest/views/artigos/format?_format=json, but it returns an error.

UPDATE

I follow the @Ismail Cherri suggestion, seems a progress in the question but give me back :

"message":"The used authentication method is not allowed on this route."

In drupal website the config :

/entity/view/{view} is set to :

GET formats: hal_json, json authentication: basic_auth

and /entity/entity_view_mode/{entity_view_mode} is set to :

GET formats: hal_json, json authentication: basic_auth

anyone could help?

Orthophilos

How can I replace the date picker with a text field that shows a date picker when it has the focus?

4 days 8 hours ago

I installed the Date Picker module, which works fine. This is what appears when I add the datepicker element to the form.

This is the code I use to add the datepicker element.

$form['date'] = array( '#title' => t('Select your birthdate'), '#type' => 'datepicker', '#date_format' => 'd/m/Y', '#date_year_range' => '-100:+0', '#default_value' => date("Y-m-d H:i:s", time()), );

I want to display a text field; when it has the focus, the calendar should be shown.

How should I change the code to make it possible?

user46175

500 error without any error log entry

4 days 9 hours ago

Migrated a Drupal 8 site to another server running apache2 PHP 5.5.9 (should be supported). Apache returns 500 when index.php requested, but no errors are logged anywhere. I tested by forcing an intentional PHP error in index.php and the log contains PHP errors.

I also excluded database connection problems. Taking settings.php out redirects me correctly to /core/install.php and no error is thrown.

BrrBr

How to inject code into node body after x paragraph

4 days 10 hours ago

Trying to figure out if there is a way to inject code after the first or second paragraph on a node.

More specifically I am trying to inject an Adsense ad.

So far I haven't been able to find a solution or module that will do this.

Can anyone help?

I am not using paragraphs module. Just looking how to inject code right after the third or fourth

tags on the body of the node.

Progonat

How do I print an exposed filter block in a template file?

4 days 11 hours ago

I have a view with an exposed taxonomy filter. I configured it to be displayed as a separate block so that I can print it another twig template. I tried this.

/** * Implements hook_preprocess_block() for block.html.twig. */ function themename_preprocess_block(array &$variables) { $variables['featured'] = views_embed_view('view_name', 'contextual_filter_block_machine_name'); }

Then I used {{ featured }} in the block template, but it doesn't work.

Is there another way to do this?

Binny

How to redirect into a specific page variant

4 days 12 hours ago

I installed panels, page manager, ctools and page manager redirect.

I made a (panel) page say foo1 - admin/structure/pages/add with variant type Panel. In this I put 5 variants named foo1variant1, foo1variant2, foo1variant3, foo1variant4, foo1variant5,

I also setup a page manager redirect say foo2: - admin/structure/pages/add with variant type redirect. In the end I should give the url it should go to foo1 en into foo1variant3, .

How to do this?

Justme

entity:file:undefined" plugin does not exist upload using curl to jsonapi

4 days 13 hours ago

I'm using php_curl to POST a binary image to my local D8.8 app but it keeps returning a 500 error:

The "entity:file:undefined" plugin does not exist. Valid plugin IDs for Drupal\Core\TypedData\TypedDataManager are: helpful list of D8 entities.

Using the example "Flow 1" from this doc page, I started out with this:

$binary = file_get_contents('Wilson.jpeg'); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,'http://localhost/jsonapi/node/doctor/field_photo'); curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_setopt($ch, CURLOPT_USERPWD, "admin:mypwd"); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $binary); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/octet-stream', 'Accept: application/vnd.api+json', 'Content-Disposition: file; filename="Wilson.jpeg"', )); curl_setopt($ch, CURLOPT_POSTFIELDS, $binary); $result = curl_exec($ch);

Searching I read that D8 is more strict about entity bundles, I can report that my field_photo for the doctor content type is instantiated as an image. Examining my app's /admin/structure/file-types/manage/image/edit I can see in the Known Mime Types section that application/octet-stream and image/jpeg exists and standing by. Rereading the error Drupal seems to perceive that this is a file but isn't clear what kind it is. I thought I was being clever and changed the Content Disposition from 'file' to 'image' but no such luck. Exact same error returned. Swapping it out to one of the suggested to 'entity:file:image' did not change the error message. It suggests to me that I need to do something in this curl header to prompt Drupal to understand that this is a file that has a plugin established for it.

Digging into the stacktrace I see that it's generating "entity:file:undefined" because the Bundle property for this entity is "undefined". Working backwards, in context of the doctor node definition, the field passes through the MimeTypeGuesser class has figured out that it is a jpeg and its attributes. But this gets lost when passed to the TemporaryJsonapiFileFieldUploader where it attempts to validate the File.

I've attempted adding "application/octet-stream" as a second entry underneath the "image/*" on the /admin/structure/file-types/manage/image/edit page but nothing changes. How should I associate its bundle to "image" so that I end up with "entity:file:image" and I can move on?

One thing that bothers me is that file uploading was added to the 8x-2.x branch and I'm reading that it is part of core. I'm on 8.8.5 and am assuming I have the latest after running composer update. I've checked some of the file diffs on jttps://git.drupalcode.org/project/jsonapi/ and it appears the files I'm working on are current, but it bothers me that I haven't resolved this. The json output from this module returns "jsonapi":{"version":"1.0" which is an indicator of the external jsonapi specification, not the drupal module.

sam452

Display summary + read more links if body content is long, otherwise display body alone

4 days 14 hours ago

We have a content type which has a customized template. In general, the body content of these nodes is short -- one to two sentences at most.

In some cases, however, the body content is a paragraph or more.

If the body content is shorter than 200 words, we would like to display the body field as-is.

If the body content is longer than 200 words, we would like to display the summary with a customized "read more" link.

Besides digging into the content array and counting words in the template, is there a graceful way to do this with view modes or field templates?

At the moment our clunky solution is to render both display types and swap between them with javascript, but this displays the "read more" link even when the body content is short enough to be displayed without the need for a summary.

node--custom.tpl.php <?php // Other fields above.. $summary = field_view_field('node', $node, 'body', [ 'label' => 'hidden', 'type' => 'text_summary_or_trimmed', ]); // Render summary of body, which is visible by default print render($summary); // Render full body as hidden with 'element-invisible' class (see field--body--timeline.tpl.php) print render($content['body']); ?> field--body--custom.php <?php if($element['#view_mode'] !== 'full'): // Display trimmed version ?> <div class="<?= $classes; ?>"> <!-- this is the summary field --> <?php foreach($items as $delta => $item): print render($item); endforeach; ?> <a class="fullTextButtonOn">Read More&hellip;</a> </div> <?php else: // Display full body text with the element-invisible class and hidden by default ?> <div class="element-invisible <?= $classes; ?>"> <!-- this is the full body field --> <?php foreach($items as $delta => $item): print render($item); endforeach; ?> <a class="fullTextButtonOff">&hellip;Read Less</a> </div> <?php endif; ?> Resulting HTML on render <div class="field field-name-body field-type-text-with-summary field-label-hidden"> <!-- this is the summary field --> <p>Leverage agile frameworks to provide a robust synopsis for high level overviews. Iterative approaches to corporate strategy foster collaborative thinking to further the overall value proposition. Organically grow the holistic world view of disruptive innovation via workplace diversity and empowerment.</p> <a class="fullTextButtonOn">Read More…</a> </div> <div class="element-invisible field field-name-body field-type-text-with-summary field-label-hidden"> <!-- this is the full body field --> <p>Leverage agile frameworks to provide a robust synopsis for high level overviews. Iterative approaches to corporate strategy foster collaborative thinking to further the overall value proposition. Organically grow the holistic world view of disruptive innovation via workplace diversity and empowerment.</p> <p>Bring to the table win-win survival strategies to ensure proactive domination. At the end of the day, going forward, a new normal that has evolved from generation X is on the runway heading towards a streamlined cloud solution. User generated content in real-time will have multiple touchpoints for offshoring.</p> <a class="fullTextButtonOff">…Read Less</a> </div>
PHP84
Checked
22 hours 5 minutes ago
most recent 30 from drupal.stackexchange.com
Subscribe to Drupal StackExchange feed