Setting Field-level Visibility (Public/Private) in Drupal

Overview In Omeka S, visibility can be set at the field level (public/private). These are notes on how to achieve this in Drupal. Installation c o m v p e o n s d e o r r . / p b h i a n r / d r r e u q s u h i r e e n ' f d i r e u l p d a _ l p / e f r i m e i l s d s _ i p o e n r s m i s s i o n s : ^ 1 . 4 ' Configuration Navigate to the edit page for a specific field of a content type, such as: ...

August 16, 2024 · 3 min · Nakamura

Drupal: Troubleshooting Cache Clear Errors

Overview When clearing the cache in Drupal, the following error sometimes occurred. I n v T e e C h n n h e t d e o c s s r k e e / E r r b x v v i c i i n e c c / p e e d t r i " " u o a u s n c s h O c e n e r c I s . r n s d v _ a a c t l h a i e " d c . R k e . f c e o r n e t n a c c e t B _ e p h e a r v s i o o n r a P l a " s s h . a p s h p a l d i e n p e e n 8 d 8 e : n c y o n a n o n - e x i s t Here are my notes on how to resolve this error. ...

August 16, 2024 · 2 min · Nakamura

Bulk Deleting Multiple Content Items Using the Drupal REST API

Overview I had the opportunity to bulk delete multiple content items using the Drupal REST API, so this is a memo of the process. References For a method to bulk delete content without using the REST API, please refer to the following. Preparation First, enable the HTTP Basic Authentication module and the JSON:API module. Additionally, enable DELETE in REST resources. /admin/config/services/rest Execution Example The following custom library is used. ...

July 14, 2024 · 5 min · Nakamura

Reverse Proxy Settings for Drupal Running with Docker + Traefik

Overview I was running Drupal with HTTPS using Docker + Traefik, as introduced in the following article. At the time, with Drupal’s default settings, URLs were set with http as shown below. The problem with this was that, for example, when setting up Google account login as described in the following article, the redirect URL started with http, while the Google Cloud console requires URLs starting with https. This discrepancy caused authentication to fail in some cases. ...

July 4, 2024 · 3 min · Nakamura

Drupal: Setting Pre-filled Values Using the Prepopulate Module

Overview When accessing the Drupal content creation screen, I was able to set pre-filled values by specifying query parameters, so this is a memo of the process. The following module is used. https://www.drupal.org/project/prepopulate Usage For example, when adding new content to a content type called “poems,” add query parameters as follows. </node/add/poems?edit[field_spot][widget][0][target_id]=1&edit[title][widget][0][value]=テスト> As a result, the registration screen is displayed with the initial values pre-filled as shown below. Summary I hope this serves as a useful reference. ...

June 12, 2024 · 1 min · Nakamura

Logging into Drupal Programmatically

This is a personal note on how to log into Drupal programmatically. The following article was helpful: https://drupal.stackexchange.com/questions/185494/how-do-i-programmatically-log-in-a-user-with-a-post-request c } u - - ' r h d l e a a t " " d a n p - e a a l r ' m s o { e s c ' " " a C : : t o i n " " o t a a n e d d n m m ' t i i h - n n t T " " t y , p p : e / : / d a r p u p p l a i l c . a d t 8 i / o u n s / e j r s / o l n o ' g i n ? _ f o r m a t = j s o n ' By sending a request like the above, I was able to obtain a response like the following: ...

May 31, 2024 · 2 min · Nakamura

Bulk Exporting Registered Content in CSV Format from Drupal

Overview I had the opportunity to export registered content from Drupal in CSV format, so here are my notes. I used the following module. https://www.drupal.org/project/content_export_csv Installation It could be installed using the standard method. c o m v p e o n s d e o r r / r b e i q n u / i d r r e u s ' h d r e u n p a c l n c t o e n n t t e _ n e t x _ p e o x r p t o _ r c t s _ v c s v : ^ 4 . 7 ' Usage After installation, navigating to Administration > Content > Content displays the “Export Content” button. ...

May 30, 2024 · 1 min · Nakamura

Triggering GitHub Actions from Drupal Events

Overview This is a memorandum on how to trigger GitHub Actions from Drupal events. The following site was helpful: https://qiita.com/hmaruyama/items/3d47efde4720d357a39e Pipedream Configuration Create a workflow that includes a trigger and a custom_request. For the trigger, please refer to the following: https://qiita.com/hmaruyama/items/3d47efde4720d357a39e#pipedream側の設定 In custom_request, configure the dispatch settings. https://docs.github.com/ja/rest/repos/repos?apiVersion=2022-11-28#create-a-repository-dispatch-event Configure the settings as follows: c u r - - - - h - l X H H H t d t - P " " " p ' L O A A X s { S c u - : " \ T c t G / e e h i / v \ p o t a e t r H p n : i u i t z b . _ a a - g t p t A i y p i p t p l o i h e i n - u " c : V b : a e . " t B r c w i e s o e o a i m b n r o / h / e n r o v r : e o n p k d < 2 o " . Y 0 s } g O 2 / ' i U 2 O t R - W h - 1 N u T 1 E b O - R + K 2 / j E 8 R s N " E o > P n " \ O " / \ d \ i s p a t c h e s \ ...

May 28, 2024 · 3 min · Nakamura

Getting a List of Untranslated Nodes in Drupal

Overview I had the opportunity to get a list of untranslated nodes in Drupal, so this is a personal note for future reference. Method There are various approaches, but this time I use JSON:API. Let’s assume the master language is Japanese (ja) and the translation language to add is English (en). Using JSON:API, for example, for a taxonomy called collection, you can retrieve it with the following: https://xxx/jsonapi/taxonomy_term/collection Additionally, by adding /en as follows, if a translation node exists, that information is returned. ...

May 22, 2024 · 3 min · Nakamura

Case-Insensitive Search in Drupal's Search API

Overview This is a memo on performing case-insensitive search when using Drupal’s Search API. Method Access the following page and check “Ignore case.” /admin/config/search/search-api/index/<content_type>/processors Furthermore, in the Processor settings at the bottom of the screen, select the fields to which you want to apply this processing. It was also possible to select all fields as shown below. By performing reindexing, the above settings will be reflected. Summary I hope this serves as a helpful reference. ...

May 6, 2024 · 1 min · Nakamura

Handling the Error: Input value "page" contains a non-scalar value

Overview I addressed the same error in the following article. However, there were cases where the error could not be resolved even after applying the above fix, so I describe additional measures here. Error Details The error details are as follows. In particular, it occurred when jsonapi_search_api_facets was enabled. { " " " " " " } } } } " { " " " " " " } " " } } " " " } " " j v m l s h , e t s d l v h , i h , s f l , m e s e e i e r r i t e i i r n r o i i e x o r t n l e r t a t n a e f e u l n t c n s a k f f o l t a k " f o f r e e a e a i " s " " r e u i s : " " " c " " " p p o : " : : s " s l " : : : e : : : t i n : " : " " : { " i " " { { " : : : " { " : " 8 { o : : { h " { h h / 3 n t [ B " " t t { a " { " t a 4 I t t p : 1 p d 0 n p p p . : 0 p : : / " 0 / R " u / / v S " / e , t / / e y , j q l w n m s u v o w d f o e a c w o o n s l a . r n a t u l w / y p " e h 3 s \ i , o . y \ . \ s o m C o " t r f o r p : g o m g a 6 / n p / g 1 P y o f e 1 r / n o \ 1 o h e r " 7 t t n m / o t t a c w c p \ t o e o - \ / n b l k H 1 t / s e t . a j / r t 0 i s r n p / n o f e F " s n c l o a 2 / u a p 6 H n i 1 t d n / 6 t a o i / p t n n r K i - d f e o s e c r n c x 2 n \ a / 6 e \ l d 1 l E a o 6 . x r c - p c u s h e v m e p p a e c " t l n 1 , i u t 0 o e ? . n . p h \ " a t \ , g m B e l a % # d 5 s R B e e l c q i 1 u m 0 e i . s t 4 t % . E 5 1 x D " c = e 2 p 4 t & i s o o n r : t = I f n i p e u l t d _ v i a d l " u e \ " p a g e \ " c o n t a i n s a n o n - s c a l a r v a l u e . i n / a p p / v e n d o r / s y m f o n y / h t t p - f o u n d a t i o n / I n p u t B a g . p h p : 3 8 \ n S t a c k t r a c e : \ n # 0 / a p p / w e b / m o d u l e s / c o n t r i b / f a c e t s / s r c / P l u g i n / f a c e t s / u r l _ p r o c e s s o r / Q u e r y S t r i n g . p h p ( 9 2 ) : S y m f o n y \ \ C o m p o n e n t \ \ H t t p F o u n d a t i o n \ \ I n p u t B a g - > g e t ( ' p a g e ' ) \ n # 1 / a p p / w e b / m o d u l e s / c o n t r i b / f a c e t s / s r c / P l u g i n / f a c e t s / p r o c e s s o r / U r l P r o c e s s o r H a n d l e r . p h p ( 7 6 ) : D r u p a l \ \ f a c e t s \ \ P l u g i n \ \ f a c e t s \ \ u r l _ p r o c e s s o r \ \ Q u e r y S t r i n g - > b u i l d U r l s ( O b j e c t ( D r u p a l \ \ f a c e t s \ \ E n t i t y \ \ F a c e t ) , A r r a y ) \ n # 2 / a p p / w e b / m o d u l e s / c o n t r i b / f a c e t s / s r c / F a c e t M a n a g e r / D e f a u l t F a c e t M a n a g e r . p h p ( 3 3 9 ) : Solution I modified the buildUrls method in the file mentioned above. ...

April 30, 2024 · 14 min · Nakamura

Verifying OAuth Authentication Using Drupal's Simple OAuth and Postman

Overview We verify OAuth authentication using Drupal’s Simple OAuth and Postman. I previously wrote the following article, but this time I will explore it further. Configure Simple OAuth in Drupal Please refer to the following. /en/posts/e4ce978db12227/#oauthクライアントの作成 Postman When the grant type is password For /oauth/token, the following was specified in Body > x-www-form-urlencoded: Key Value grant_type password client_id {created CLIENT_ID, e.g., gt8UKlKltI4qs1XP5KLucIXiYw9ulGb0xS4RyO437dc} client_secret {created CLIENT_SECRET, e.g., test} username {username, e.g., yamato} password {password, e.g., yamato} As a result, the following JSON was returned: ...

March 2, 2024 · 11 min · Nakamura

Drupal: Registering Files from URLs Using the Feeds Module

Overview This describes how to register files from URLs using the Feeds module. The following was helpful. https://www.drupal.org/docs/contributed-modules/feeds/feeds-howtos/importing-files Method Find the file field from the dropdown list and create a mapping target for the file or image field. For “File ID,” specify a mapping to the full URL (including the http/https prefix). Select “File ID” under “Reference by.” Configure the action so that the feed processes existing files. After configuring these changes, save the mapping. ...

January 23, 2024 · 1 min · Nakamura

How to Bulk Delete Files in Drupal

This is a memo on how to bulk delete files in Drupal. The following was helpful. https://www.drush.org/12.x/commands/entity_delete/ d r u s h e n t i t y : d e l e t e f i l e I hope this serves as a useful reference for situations such as when files can no longer be viewed due to errors like Drupal\Core\File\Exception\InvalidStreamWrapperException. ...

January 23, 2024 · 1 min · Nakamura

Handling Private Files in Omeka S

Overview In Omeka S, you can set public/private settings for each resource (item sets, items, media, etc.), but for files such as images associated with media, even if the private setting is applied, anyone who knows the file URL can access it. Typically, the URL follows this pattern: <Omeka installation directory>/files/original/<hash value>.jpg If the private setting is applied to the media, it would be rare for this file URL to be known, but there are cases where you want to avoid a situation where “anyone with the link” can access it. ...

January 14, 2024 · 4 min · Nakamura

Trying OAuth2 Authentication for REST Resources Using Drupal's simple_oauth Module

Overview Drupal’s Simple OAuth (OAuth2) & OpenID Connect module is described as an implementation of the OAuth 2.0 Authentication Framework RFC. https://www.drupal.org/project/simple_oauth For related articles, please also refer to examples of cookie authentication and JWT authentication. Installation There appear to be version 5.x and 6.x of the simple_oauth module, but this time version 5.x is used. Install with the following: c o m p o s e r . p h a r r e q u i r e ' d r u p a l / s i m p l e _ o a u t h : ^ 5 . 2 ' However, when using Sakura Rental Server, the following error occurred. PHP's sodium extension was required. ...

January 2, 2024 · 19 min · Nakamura

Trying the Drupal Social Auth GitHub Module

Overview I will try the Drupal Social Auth GitHub module. https://www.drupal.org/project/social_auth_github/ This module is described as follows: Social Auth GitHub allows users to register and login to your Drupal site with their GitHub account. The goal is to enable login using a GitHub account as shown below. Installation c v o e m n p d o o s r e / r b . i p n h / a d r r u r s e h q u e i n r e s o ' c d i r a u l p _ a a l u / t s h o _ c g i i a t l h _ u a b u t h _ g i t h u b : ^ 4 . 0 ' The above installation also enables social_auth and social_api. ...

January 2, 2024 · 2 min · Nakamura

Testing Drupal REST Resource Cookie Authentication Using Postman

Overview In the following article, I tried JWT authentication using the JWT module. This time, I will try cookie authentication. Installation If the restui module is not installed, install and enable it with a command like the following. c v o e m n p d o o s r e / r b . i p n h / a d r r u r s e h q u e i n r e r e ' s d t r u u i p a l / r e s t u i : ^ 1 . 2 1 ' Configuration This time, I will use cookie authentication as shown below. For details on the configuration method, please refer to the related article at the beginning. ...

January 1, 2024 · 2 min · Nakamura

Trying the Drupal JSON Web Token Authentication Module

Overview I will try the Drupal JSON Web Token Authentication module. https://www.drupal.org/project/jwt I referenced the following page. https://preston.so/writing/decoupled-drupal-authentication-with-json-web-tokens/ Note that the following is a similar module. https://www.drupal.org/project/rest_api_authentication JWT authentication using the above module is described here. https://www.drupal.org/docs/contributed-modules/api-authentication/jwt-authentication However, as described in the following article, it appears that using JWT authentication with the above module requires a paid plan. Therefore, this time I will try the jwt module instead. Installation and Activation jwt module ...

December 31, 2023 · 13 min · Nakamura

Investigation of the Drupal REST & JSON API Authentication Module

Overview I will try JWT authentication, referencing the following article. https://www.drupal.org/docs/contributed-modules/api-authentication/jwt-authentication However, after trying it, it appeared that a paid plan subscription was required to use JWT authentication, and the investigation stopped there. Prerequisite: Download and Installation Install and enable the following two modules. https://www.drupal.org/project/rest_api_authentication https://www.drupal.org/project/restui c c v o o e m m n p p d o o o s s r e e / r r b . . i p p n h h / a a d r r r u r r s e e h q q u u e i i n r r e e r e ' ' s d d t r r _ u u a p p p a a i l l _ / / a r r u e e t s s h t t e _ u n a i t p : i i ^ c _ 1 a a . t u 2 i t 1 o h ' n e n t i c a t i o n : ^ 2 . 0 ' Steps to Configure JWT-Based API Authentication Follow the instructions below to enable the API and set up JWT-based API authentication. ...

December 31, 2023 · 2 min · Nakamura