ultrabob's blog

Drupal 8/9: Getting an array of target_ids from a multi-entry entity reference field

$target_ids = array_column($entity->field_name->getValue(), 'target_id);

Ajax form notes

The #ajax['wrapper'] property includes the HTML ID of a page section that should be replaced (or altered in some other way).

The #ajax['callback'] tells the Form system what callback should be called after the Ajax call happens and the form is rebuilt.

SimpleTest example module notes

The project I'm working on nicely manages to involve segments of drupal that I didn't learn as much about with the last project. I'm going back and working through the relevant submodules of the examples module to try to get a clear understanding of the drupalish way to handle things. The first thing on my list is simpletest. This is something I could/should have learned for the last project, but I had so much going on that I never got to it. It probably would have saved me time if I'd been disciplined, so I'll try to be more test-driven this time.

Fun with CSS child-selectors, making a comma separated series with oxford commas

This all started with a question on Drupal Answers in which I was trying to figure out how to manipulate the render array of paragraphs module output to turn it into a comma separated list of field content.

It turned into a fun exploration of css selectors that I haven't messed with in a long time. Here is a jsfiddle for you to follow along with.

Field Collection: multi-entry, add another item takes forever SOLVED

Now that I've managed to track down the patch for this issue I realize that I probably wasted a lot of time trying to find alternatives to field collections, and even making a start on my own compound field type.

PDFPreview User error: ImageMagick error 1: convert: no images defined

On my local development environment (a macbook pro running El Capitan), whenever I installed PDFPreview and tried to view a page that utilized it, I would get an error like:

User error: ImageMagick error 1: convert: no images defined `/path/to/pdfpreview/folder/filetowrite.jpg' @ error/convert.c/ConvertImageCommand/3241

File access control

So I've asked questions on a reddit thread, and I've asked some questions on drupal answers. The people who answer are extremely helpful, and if I get some further answers it may change my mind, but at this stage, it seems to me that my best approach for managing access by role to individual files as part of a node with its own independent access controls might be to continue on the track I've been on:

Backing off on using file entities to solve my file permissions issue

After a couple of days of struggling to populate the fields provided by file entity as part of my migrate module migration, I have thrown in the towel. I opened an issue with a feature request for migration support with the new version of the file entity module, but in the unlikely event that my request gets any traction I will probably have moved way past the point that I can still use it.

Here is a quick review of the things I tried:

Struggling with Files and PDF Thumbnails in Drupal 7

I'm working on building a document library in Drupal 7. The project has presented a lot more challenges than I initially anticipated, and one of them is the presentation of files. Each entry can either be an internal only entry, or be visible to the world. Each entry can also contain multiple files, and each of those can either be internal only or visible to the world. I am migrating from another system with a lot of content in place. In the current system, each entry has an optional cover image, files are just listed by filename. That's where the trouble begins.

Subscribe to RSS - ultrabob's blog