Drupal: An Example of Searching Nested Fields

Overview In the following article, I investigated how to search nested fields using Strapi. This time, I will investigate how to do the same thing with Drupal. For this investigation, Book and Author content has already been registered in the following article. The following article was helpful for filtering methods. https://www.drupal.org/docs/core-modules-and-themes/core-modules/jsonapi-module/filtering Search Examples The following searches are performed against: /jsonapi/node/book? Search for books containing an author with hobby=dance SHORT filter[field_authors.field_hobby]=dance ...

April 24, 2023 · 7 min · Nakamura

Drupal: Example of Bulk Registration and Updates Using Feeds

Overview In the following article, I investigated search methods for nested fields using Strapi. This time, as a preparation for doing the same thing in Drupal, this is a note on how to perform bulk registration and updates of content. To set up a structure similar to the above article, we will work with two content types: Book and Author. Creating Content Types Create the Book and Author content types. ...

April 23, 2023 · 2 min · Nakamura

Drupal: Adding Content Types and Fields Using Custom Modules

Overview This is a memo on how to add content types and fields using Drupal custom modules. The following two articles were helpful. https://www.drupal.org/docs/drupal-apis/entity-api/creating-a-custom-content-type-in-drupal-8 https://www.digitalnadeem.com/drupal/how-to-create-content-type-fields-and-view-while-installing-custom-module-in-drupal-9-using-configuration-manager/ Car Brand Example Following the first article introduced above, I was able to add a content type “Car Brand” with a “body” field. Note that the above article skips the part about creating the custom module. First, create the following folder and file. n d p t v c a e a y e o m s c p r r e c k e s e : r a : i _ i g o v f p e m n e o t : o : r o i d s b o C u 1 i a n u l . o r : s e 0 n t _ S o r a m e m q p u l i e r e m m o e d n u t l : e ^ 8 ^ 9 Adding Custom Fields Using the above as reference, I was able to add a content type, but to add custom fields, I needed to add both a Field and a Field storage. ...

April 21, 2023 · 10 min · Nakamura

Drupal: Linking Content of Different Content Types to Each Other

Overview I investigated how to link content of different content types to each other, and here are my notes. Specifically, as shown below, item 1 is connected to a content item called image 1 through a field called iiif_image2. The goal is to add a link to item 1 on the image 1 page. I referenced the following article for this implementation. https://drupal.stackexchange.com/questions/255447/view-for-entity-reference-reverse-backwards-forwards Method Adding a View Navigate to /admin/structure/views and click “+ Add view” ...

April 20, 2023 · 2 min · Nakamura

Drupal: Creating Custom REST Resources

Overview I created a custom REST resource by following the instructions below. https://www.drupal.org/docs/drupal-apis/restful-web-services-api/custom-rest-resources By following the above article, I was able to obtain a JSON result from the following URL. /demo_rest_api/demo_resource { } " m e s s a g e " : " H e l l o , t h i s i s a r e s t s e r v i c e " REST UI Module The above article included the following note: ...

April 20, 2023 · 7 min · Nakamura

Creating a Custom API Using Drupal's RESTful Views

Overview This is a memo about creating a custom API using Drupal’s RESTful Views, based on the following article. https://acret.jp/drupal/node/434 In addition to the content of the above article, I also describe how to configure pagination. Creating Views I followed the instructions on the site mentioned above. Enabling Pagination I referenced the following article. https://www.drupal.org/forum/support/post-installation/2015-12-04/rest-export-pagination Select the Views Pager. I set it to Full as shown below. Mini also seemed to work fine. ...

April 20, 2023 · 1 min · Nakamura

Displaying the Total Number of Results in Drupal Views

Overview I looked into how to display the total number of results in Drupal Views, so here is a quick note. The total number of search results is displayed as shown below: Method I referenced the following article: https://ostraining.com/blog/drupal/count-views/ Access the following page: /admin/structure/views/view/content Click the Add button next to Header. Select “Result summary”. Click Apply, then click Save. Summary I hope this serves as a useful reference. ...

April 20, 2023 · 1 min · Nakamura

Search Using Drupal Search API in Next.js for Drupal (Faceted Search, etc.)

Overview I tried Next.js for Drupal. https://next-drupal.org/ By following the “Get Started” guide, I was able to integrate Next.js with Drupal. https://next-drupal.org/learn/quick-start Additionally, the following article introduces an implementation example for faceted search. https://next-drupal.org/guides/search-api This article is my notes specifically on implementing the latter, faceted search. Search API Create a Server and index as follows. The official site provides the following as a reference: https://www.drupal.org/docs/contributed-modules/search-api For a Japanese-language reference: https://www.acquia.com/jp/blog/introduction-to-search-api-1 ...

April 17, 2023 · 8 min · Nakamura

How to Bulk Delete Content in Drupal

Overview I looked into how to bulk delete content in Drupal, so this is a memo. The following article was helpful. https://www.webwash.net/how-to-bulk-delete-content-in-drupal/ The following three methods were introduced. Using Drupal Core UI Using Drush Using Drupal Views Bulk Operations (VBO) Using Drupal Core UI The following is a translation of the original description. If you have a small Drupal site and fewer than about 300 nodes to delete, you should use this method. This is because the Drupal Core UI only allows deleting 50 nodes at a time by default. As the site grows larger, this becomes tedious. ...

April 14, 2023 · 4 min · Nakamura

Connecting Drupal with Amazon OpenSearch Service

Overview I had the opportunity to connect Drupal with Amazon OpenSearch Service, so this is a personal note for future reference. The following article was helpful. https://www.acquia.com/jp/blog/intergration-with-drupal-and-elasticsearch Module Installation In addition to drupal/search_api and drupal/elasticsearch_connector, it was necessary to install nodespark/des-connector. (There may be room for improvement in how version specifications are handled.) c c c o o o m m m p p p o o o s s s e e e r r r r r r e e e q q q u u u i i i r r r e e e " ' " n d d o r r d u u e p p s a a p l l a / / r s e k e l / a a d r s e c t s h i - _ c c a s o p e n i a n : r e ^ c c 1 h t . _ o 2 c r 9 o : ' n ^ n 7 e . c x t - o d r e v ^ " 7 . 0 @ a l p h a " Then, enable them with the following. ...

April 13, 2023 · 5 min · Nakamura

Trying GraphQL with Drupal

Overview I tried GraphQL with Drupal, so this is a personal note for future reference. The following document was helpful. https://drupal-graphql.gitbook.io/graphql/ This assumes Drupal installed on Amazon Lightsail. Module Installation Install the following module. https://www.drupal.org/project/graphql However, it was necessary to install the following module beforehand. https://www.drupal.org/project/typed_data As a result, the installation was completed with the following commands. c c c d o o m m / p p h o o o s s m e e e r r / b r r i e e t q q n u u a i i m r r i e e / s ' ' t d d a r r c u u k p p / a a d l l r / / u t g p y r a p a l e p d h _ q d l a : t ^ a 4 : . ^ 4 1 ' . 0 @ b e t a ' Module Installation from GUI I checked all three related modules below and installed them. ...

April 12, 2023 · 2 min · Nakamura

Registering Taxonomies and Adding Them to Content in Drupal Using Python

Overview This is a continuation of the following series. This time, we will register taxonomies and add them to content. Registering Taxonomies A taxonomy called ne_class was created in advance through the GUI. It can be listed at the following URL. /jsonapi/taxonomy_term/ne_class Below is the program for registering a new taxonomy. Please configure host, username, and password as appropriate. p } _ u r r a t r . y y l = j l p s o " } e = r o a d e n d a = f q ( t " u ) = a " " } " { e " t a n h s { : y t e o t p t _ s s { e r " c t . " i n l } p : b a a / o u m s j s " t e s s t t e " " o ( a s : n u x " a r o : " p l n 干 i , o { 瀬 / m " t h y , a e _ x a t o d e n e r o r m m s - y = - _ h n t e e e a _ r d c m e l / r a { s s _ , s t " y a , p u e t } h " = ( u s e r n a m e , p a s s w o r d ) , j s o n = p a y l o a d ) The following result is obtained. ...

April 11, 2023 · 5 min · Nakamura

Updating and Deleting Drupal Content Using Python

Overview In the following article, I described how to create new content. This time, I’ll try updating and deleting existing content. Filtering Items With the following program, you can retrieve registered content. This time, I retrieved content with the title “Pre-update title.” res["data"] is an array. u p h q } i f f f e r r l s a o u t i o i n e e e s s e e l r l d = s n r s t r m t t p ( n w y " _ e k f e o r = r a o = t t r e i r i e e m r = i y s y l _ n q r s e d " t p , t s t u . [ x { l e = e t e j ' = = x e v r r = s s d x " = [ a s t o a " " " : ] l . = f s n t x x " u a ' . ( a x x " a e p ' { g ) ' x x 更 r p & h e ] " " 新 t i e ' o t ) 前 i n n . s ( の c d j t e タ l q ( o } n イ e u f i / d ト " e ' n j p ル r f ( s o " y i f o i . l i n n i t l a t t e t p , e r e i m [ r / h s { s n e ( k ) o a ) e d d : y e e } / r ] { s = i = { t h v e e a m a l _ d u t e e y r } p s ' e , ) } ? a { u f t i h l = t ( e u r s _ e s r t n r a } m ' e , p a s s w o r d ) ) Getting the ID of the Content to Update An ID like 730f844d-b476-4485-8957-c33fccb7f8ac is obtained. ...

April 11, 2023 · 4 min · Nakamura

Adding Content to Drupal Using Python

Overview I had an opportunity to add content to Drupal using Python, so this is a memo of the process. I referenced the following article. https://weimingchenzero.medium.com/use-python-to-call-drupal-9-core-restful-api-to-create-new-content-9f3fa8628ab4 Preparing Drupal I set it up on Amazon Lightsail. The following article is a useful reference. https://annai.co.jp/article/use-aws-lightsail Modules Install the following modules. HTTP Basic Auth JSON:API RESTful Web Services Serialization Changing JSON:API Settings Access the following page to change the settings. </admin/config/services/jsonapi> Python Set {IP address or domain name} and {password} as appropriate. ...

April 11, 2023 · 6 min · Nakamura