Updating Drupal on Sakura Rental Server

Overview I had the opportunity to update Drupal on a Sakura rental server, so this is a memo of the procedure. First, I referenced the following site. https://www.drupal.org/docs/updating-drupal/updating-drupal-core-via-drush However, it contained the following note. Use Composer to manage Drupal dependencies. Drush 9 and newer no longer supports updating Drupal. So I also referenced the following. https://drupalfan.com/drupal10を最新版にアップデートする/ Procedure ! The procedure may contain incorrect or unnecessary steps, so please use it as a reference only. ...

December 22, 2023 · 4 min · Nakamura

Drupal Module Development: Searching with Variant Characters in Mind

Overview While developing a system using Drupal, I needed to implement search functionality that considers variant characters (itaiji), so I created a custom module to achieve this. (There may already be an existing module that does the same thing, but I was unable to find one.) It is published in the following repository: https://github.com/nakamura196/Drupal-module-itaiji Usage Configuration Access /admin/config and click the Itaiji link under the Search and metadata section. ...

December 21, 2023 · 1 min · Nakamura

Drush Command Cheat Sheet

Overview These are notes on frequently used commands during Drupal module development. Clearing Cache d r u s h c r Importing Translation Files The following is an example of importing a Japanese language file for a module called itaiji. d r u s h l o c a l e : i m p o r t j a / a p p / w e b / m o d u l e s / c u s t o m / D r u p a l - m o d u l e - i t a i j i / t r a n s l a t i o n s / i t a i j i . j a . p o Reinstalling a Module d r u s h p m - u n i n s t a l l i t a i j i & & d r u s h e n i t a i j i

December 20, 2023 · 1 min · Nakamura

Pagination Error When Using JSON:API Search API in Drupal

When using the JSON:API Search API in Drupal, an error occurred when adding query parameters such as page[limit]. https://www.drupal.org/project/jsonapi_search_api Specifically, the following error message was displayed. Input value “page” contains a non-scalar value. Upon investigation, this was also mentioned in the following issue. https://www.drupal.org/project/jsonapi_search_api/issues/3403107 Since it was fixed in the development version 8.x-1.x-dev, I replaced it with the following. https://www.drupal.org/project/jsonapi_search_api/releases/8.x-1.x-dev As a result, the error was resolved. Whether to use the development version of the module requires consideration, but I hope this is helpful for those experiencing the same issue. ...

December 16, 2023 · 1 min · Nakamura

Drupal: Registering Multiple Values and Skip Processing Using the Feeds Tamper Module

Overview I attempted to register a CSV like the following using Drupal’s Feeds module. id title target xxx aaa 9600023 When you want to register multiple values in a single field like this, the Feeds Tamper module can be used. https://www.drupal.org/project/feeds_tamper The following article was helpful. https://acret.jp/drupal/articles/456 By configuring as follows, I was able to batch register multiple values. However, when the target column contains empty rows like the following, ...

November 13, 2023 · 2 min · Nakamura

Drupal: Displaying UUIDs

Overview This is a note on how to display UUIDs for content, as shown below. Module Installation The following module was used. https://www.drupal.org/project/uuid_extra Usage Select the “Manage display” tab for the content type where you want to display UUIDs, and move the UUID field as shown below. Summary I hope this serves as a useful reference.

November 13, 2023 · 1 min · Nakamura

Making Field Values Selectable in Drupal

Purpose This article explains how to make field value input selectable, as shown below. Below, I’ll explain both the text case and the entity reference case. Text Case Create a field called age. Here, select “List (text)”. Enter the choices as follows. As a result, the field can be edited in a “Select list” format as shown below. Furthermore, from the content type list page, click “Manage form display”. ...

October 31, 2023 · 2 min · Nakamura

Enabling Search by ID and Title When Referencing Other Content in Drupal

Introduction For example, suppose you create a content type called “Organization” in Drupal and create content items for “The University of Tokyo” and “Kyoto University.” At this point, assume that IDs from the Research Organization Registry (ROR) are also registered as follows. Title ID The University of Tokyo 057zh3y96 Kyoto University 02kpeqv85 Now, let’s try referencing this content from another content type (for example, a “Researcher” content type) using an affiliation field. When you type something like “University,” the two registered content items are displayed as shown below. ...

October 31, 2023 · 3 min · Nakamura

Drupal: Handling Errors When Updating the `uid` Field via API

When attempting to update a node’s uid field using Drupal’s JSONAPI, the following error occurred: T h e c u r r e n t u s e r i s n o t a l l o w e d t o P A T C H t h e s e l e c t e d f i e l d ( u i d ) . T h e ' a d m i n i s t e r n o d e s ' p e r m i s s i o n i s r e q u i r e d . This was resolved by changing the permissions. ...

October 26, 2023 · 1 min · Nakamura

Handling "Some resources have been omitted because of insufficient autho..." in Drupal

When using Drupal’s JSON API, I tried to retrieve field_name from a field ID using a query like the following, but got zero results. https://xxx/jsonapi/field_config/field_config?fields[field_config–field_config]=label%2Cfield_name&filter[name-filter][condition][path]=field_name&filter[name-filter][condition][operator]=IN&filter[name-filter][condition][value][1]=field_xxx1&filter[name-filter][condition][value][2]=field_xxx2&filter[name-filter][condition][value][3]=field_xxx3&filter[bundle]=yyy The meta field in the returned result indicated a permissions issue. { } " } " " } j , d m , s a e o t t n " " } a a " } a v m " " o p e e : : m i r t i " s a " } [ { t " : i " l ] t d o : i , e e { n n d t " { k " } " a : s s : i " e l " : l { " 1 f " : . { " h 0 : r " " e S , { f o " m : e " r h e t s t o p u : r / c / e j s s o h n a a v p e i . b o e r e g n / f o o m r i m t a t t e / d 1 . b 0 e / c " a u s e o f i n s u f f i c i e n t a u t h o r i z a t i o n . " , By changing the permissions for Content: Administer fields under Field UI as shown in the figure below, the permissions issue was resolved. ...

October 26, 2023 · 2 min · Nakamura

Installing drush on Drupal Built with Lando

I set up a Drupal development environment using Lando, referring to the following site. https://www.acquia.com/jp/blog/how-to-use-lando-for-building-drupal-local-environment For installing drush on it, the following was helpful. https://docs.lando.dev/drupal/getting-started.html#quick-start By running the following command, drush became available. # l a I n n d s o t a c l o l m p a o s s e i r t e r e l q o u c i a r l e d d r r u u s s h h / d r u s h I hope this serves as a useful reference for others. ...

September 28, 2023 · 1 min · Nakamura

How to Disable Twig Cache in Drupal 10.1.0 and Later

The instructions were found at the following page. https://www.drupal.org/docs/develop/development-tools/disable-caching#s-disabling-twig-caching-the-easy-way Access the following path: /admin/config/development/settings Checking the boxes on the following screen disables the cache. I hope this is helpful for others.

September 28, 2023 · 1 min · Nakamura

Displaying Images Referenced by URL in Drupal Views

Background Consider the case where you enter an image URL in a field called thumbnail with the Field type set to Link, as shown below. This time, I’ll use the following image from Irasutoya. https://3.bp.blogspot.com/-HLe8mKu9lCs/Ugsu_AAFifI/AAAAAAAAXNI/-yW12EVgQ5s/s800/book_yoko.png Here are my notes on displaying such data in Views like the following. Views I configured the following in the Views Rewrite results settings. < i m g s r c = " { { f i e l d _ t h u m b n a i l _ _ u r i } } " a l t = " I m a g e " When the Field type is set to Link, the following Replacement patterns were needed. ...

September 5, 2023 · 1 min · Nakamura

Enabling OpenAPI in Drupal

Overview I had the opportunity to enable OpenAPI in Drupal, so this is a memo. Note that the JSON:API module has already been enabled. Installing Modules Install the following two modules. https://www.drupal.org/project/openapi https://www.drupal.org/project/openapi_jsonapi As a result, JSON can be obtained from the following URL. /openapi/jsonapi Accessing the following displays “No UI …”. Next, let’s add a UI. /admin/config/services/openapi Adding a UI Install the following two modules. https://www.drupal.org/project/openapi_ui https://www.drupal.org/project/openapi_ui_redoc ...

June 14, 2023 · 1 min · Nakamura

Handling CORS Errors with Drupal's JSON:API

Overview When using the output from Drupal’s JSON:API in a separate application, a CORS error occurred. Here, I explain how to resolve the CORS error. Solution Copy the following file: /web/sites/default/default.services.yml c p / w e b / s i t e s / d e f a u l t / d e f a u l t . s e r v i c e s . y m l / w e b / s i t e s / d e f a u l t / s e r v i c e s . y m l Then, set enabled to true in cors.config: ...

June 12, 2023 · 3 min · Nakamura

Troubleshooting JSON:API Related Errors

Overview The following JSON:API related error occurred. This is a note on how to resolve it. サ T D D D f D D D D c イ y r r r a r r r r a ト p u u u c u u u u l に e p p p e p p p p l 予 E a a a t a a a a _ 期 r l l l s l l l l u せ r \ \ \ _ \ \ \ \ s ぬ o j C C s C C s b e エ r s o o y o o y l r ラ : o r m s r r s o _ ー n e p t e e t c f が D a \ o e \ \ e k u 起 r p P n m E B m \ n こ u i l e _ x r \ B c り p _ u n b t e P l _ ま a s g t r e a l o a し l e i \ e n d u c r た \ a n P a s c g k r 。 j r \ l d i r i V a し s c F u c o u n i y ば o h a g r n m \ e ( ら n _ c i u b B w ) く a a t n m M l B た p p o \ b o B u ( っ i i r P _ d r c i L て _ _ y l a u e k l i か s f \ u l l a \ d n ら e a C g t e d S e e 再 a c o i e H c y r : 度 r e n n r a r s : お c t t M ( n u t : 1 試 h s a a ) d m e p 0 し _ \ i n l b m r 1 く a P n a ( e M B e ) だ p l e g L r a r R さ i u r e i - n e e い _ g F r n > a a n 。 f i a B e a g d d a n c a : l e c e c t s t r r r e f e 5 e - u ( t a r - 4 r > m ) s c y > 5 ( b b \ e - c ) ) u B P t > r i l l s c e ( l o u \ r a L d c g f e t i ( k i a a e n ) - n c t I e > \ e e n : ( b f t I s L u a _ n t 9 i i c s s a 4 n l e o t n ) e d t u a c : ( s r n e ) \ c c ( 7 f e e ) 2 ( a \ ( ) L c J ) ( i e s L n t o ( i e _ n L n : s A i e o p n : 1 u i e 7 r F : 2 1 c a 5 ) e c 8 1 \ e 3 ) J t ) s s o : n : A c p r i e F a a t c e e ( t ) s : ( : L _ i _ n c e o : n s 2 t 1 r ) u c t ( ) : A r g u m e n t # 6 ( $ i n d e x ) m u s t b e o f t y p e D r u p a l \ s e a r c h _ a p i \ I n d e x I n t e r f a c e , n u l l g i v e n , c a l l e d i n / h o m e / j - s o k e n / d r u p a l / w e b / m o d u l e s / c o n t r i b / j s o n a p i _ s e a r c h _ a p i / m o d u l e s / j s o n a p i _ s e a r c h _ a p i _ f a c e t s / s r c / P l u g i n / f a c e t s / f a c e t _ s o u r c e / J s o n A p i F a c e t s . p h p o n l i n e 6 1 i n D r u p a l \ j s o n a p i _ s e a r c h _ a p i _ f a c e t s \ P l u g i n \ f a c e t s \ f a c e t _ s o u r c e \ J s o n A p i F a c e t s - > _ _ c o n s t r u c t ( ) ( l i n e 4 8 o f m o d u l e s / c o n t r i b / j s o n a p i _ s e a r c h _ a p i / m o d u l e s / j s o n a p i _ s e a r c h _ a p i _ f a c e t s / s r c / P l u g i n / f a c e t s / f a c e t _ s o u r c e / J s o n A p i F a c e t s . p h p ) . Solution First, enable error display. Add the following to the configuration file. ...

June 12, 2023 · 8 min · Nakamura

Disable UI: Using Drupal as a Headless CMS

I had the opportunity to use Drupal as a headless CMS and tried the Disable UI module, which restricts UI access to administrators and similar roles. https://www.drupal.org/project/disable_ui As a result, access to the top page was displayed as follows. On the other hand, the enabled JSON:API was accessible to non-logged-in users. /jsonapi/ We hope this serves as a useful reference when using Drupal as a headless CMS.

June 9, 2023 · 1 min · Nakamura

How to Use Drupal JSON:API (include and Multilingual Support)

Overview This is a personal note on how to use Drupal’s JSON:API. This time, I will cover the use of include for taxonomies and multilingual processing. Data As shown below, the taxonomy “Assistant Professor” has been assigned to the position field. /node/5 Additionally, content multilingualization is enabled, so the English versions of the title and position are also displayed as shown below. /en/node/5 JSON:API Since the above content was created with the content type “faculty”, the data list can be retrieved from the following URL. ...

June 9, 2023 · 22 min · Nakamura

Content Registration and Multilingual Support Using Drupal Key Auth

Overview In the following article, I performed content registration using Python with Basic authentication. This time, I tried API Key Authentication, referring to the following article. https://designkojo.com/post-drupal-using-jsonapi-vuejs-front-end API Key Authentication The following module was used. https://www.drupal.org/project/key_auth A “Key authentication” tab appeared on the user edit screen, allowing an API key to be generated. When using the API key, the following program can be used. i e k h } p } r r m n e e a . p d y a y = j o p d l s r o = e ' ' " o " } r o t i r A C a a d e n n ' s c o p d a q ( r t { c n i t u ) e A = e t - = a " " } e q = P p e k " t a s u I { t n e { : y t t e ' ' t y p t s s h k : - " { e r " " } . t t e T : " i t b p s t y ' y : b i o o p } a p k u t d s : ' p e e " t l y " " t / p ' y n e e " v f ( / l : o s " : a o e { i d " : l r n I c ' e : { u m d P a a - " e a p t p - { W " t o a i p a h : " i d o l r a : n d n i t t " t r / c i ' B " , e v a c s e p s n t l l h s d i e u w a e . o " p a i a o a n , t n d r p / f e _ e i v r r t r d + n o . e s o j d m x = m s . M t h a o a P y " e i n p y a n ' i t f d , + h r e n j o i r a s n e s m o " n , e n , d } ' s j / , . s j " o s , n o = n p a a p y i l / o n a o d d ) e / a r t i c l e ' Notes on Multilingual Support As a note, it appears that creating translation data is not supported. ...

June 9, 2023 · 4 min · Nakamura

Fixing TypeError: array_keys()... in Drupal

The following error occurred in the graphql module. The website encountered an unexpected error. Please try again later. TypeError: array_keys(): Argument #1 ($array) must be of type array, null given in array_keys() (line 40 of /bitnami/drupal/modules/contrib/graphql/graphql.install). I fixed the source code referring to the following article. https://www.drupal.org/project/google_tag/issues/3319621 Specifically, by rewriting as follows, the error was resolved. $ n e $ g n o e t g i o a t t i i a o t n i o = n $ = l a $ n l g a u n a g g u e a T g y e p T e y s p - e > s g - e > t g ( e ' t n ( e ' g n o e t g i o a t t i i a o t n i ' o ) n ' ? ) ? ; [ ] ; This should be fixed in the latest version, but we hope this is helpful for anyone encountering a similar error. ...

April 24, 2023 · 1 min · Nakamura