8/17/2023 0 Comments Drupal 9 cache contexts![]() To display my computed value with Views, I've created a custom Views field who display the computed "Your price" value by taking the "Discount grid" of the current user (the query() function is empty to prevent Views to search the field value on the database). So, I try many things since I've open this question, without success. I hope I didn't loose you, not easy to explain. The association between the User and the Discount grid allow me to compute the "Your price" according to the family who belongs the "Product". You can disable cache for a custom block in two different ways. ![]() To finish, the User entity has a reference field to a "Discount grid" content. Drupal The following examples will use a custom block to show how the caching works in Drupal 8 and 9, but you can use the same thing for any rendered array. ![]() With a form_alter on this content type, I list each term of the "Family product" and associate them with a textfield who take a percent of the discount value the administrator grants to this grid. Services are a way to wrap objects and use dependency injection to produce a common interface. To compute this value, I have another content-type called "Discount grid". 15th August 2021 - 23 minutes read time Drupal 8 and 9 are built upon services, with many parts of the system available through dependency injection, so it's important to understand the concepts. "Your price" is not a field, because it's a computed value. My goal is to display a computed price the for User called "Your price". This content type has a reference field to a Taxonomy called "Family product" and a "Public price" number field. I give some clarifications to my problem. In each hook I have changed the $view->element array. I already check this hook without success : Discovery and Development - E-Book Drupal 9 Module Development Sports Development Gender and Development Development of the Nervous System Children Development, Third Edition and Statistical Issues in Drug Development The PDMA Handbook of New Product Development Child Health and Development. In the configuration of the View, the cache is set "Tag based"Įach user have a specific property, and I want the Views to deal with it, without totally disable the cache of the Views. You can replace the hard-coded cache tag with a form that allows developers to set different cache tags based on configuration of the view using a module like Views Custom Cache Tags.I would like to set a user cache context to a Views, but I don't know where to do this (in what hook ?). You can force caching for all your views using a module like Views cache bully.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |