how do I create a field in content type which is a list(text) in drupal 9? - twig

I need to create a field in the content type.
The Field type is list(text). I want to add two values to this field.
Then I want to use these values in the twig code with if condition.
The twig if condition is my previous question.
I tried the answer posted previously. But it didn't work

Related

How to get a user fields value in a Twig template (Drupal 8)?

I am trying to get user field values in a Twig template. I created a text/list field in configuration->accountsettings->manage fields. The user can choose a currency e.g. USD/EUR/GBP
Afterwards, I want to get the chosen value in a Twig theme.
When I want to get the field value of a content type, I usually use:
{{ content.field_field_name.0 }}
How can I achieve the same for fields that are associated with users and not content? Thank you very much!

Kentico - Change Pagetype Field Name without blanking out current values

I have a custom page type for Staff and there's a field called Function. I have a WHERE condition in a repeater like this: Function LIKE '%insurance%' and got an error Incorrect syntax near the keyword 'Function'
From the error I guess Function is a reserved keyword, so I changed the field name to BusinessFunction. However right after changing the field name, I noticed all the values for that field become blank. If I changed it back, the values are back to normal. The question: is there a way to change the field name while keeping the values that are already there -- without access to the backend database?
Wrap the word Function in brackets like so should resolve the problem: [Function]
When you say the values of the field are blank do you mean on the display side in the repeater? Have you changed the transformation to use the new field name? Have you updated the Columns property of the repeater to use the new field name vs. the old one? It will not lose all the data, you just need to ensure all the values of the property/field name are updated everywhere including any custom code you might be using for this page type.

Kentico - Using value of added field (page type)

I need some help adding a field to a page type. I added it via "New Field". I set the field name to "ModalDataTarget".
I inserted it in the page type transformation as {% ModalDataTarget %}.
I put the value in the text field.
It isn't populating with the value I add.
Thanks in advance for any help!
Which Web Part are you using? I would verify the column is returned in the query that is being run for it.
Which transformation type are you using? ASCX? If so, you need to use <%#%> Format.
You are calling macro method in transformation . You need to use transformation methods instead:
try <%#Eval<string>("modaldatatarget")%>

Content model including a list of dates

I want to create a content model containing a list of dates of variable length. The only way I figured out how to do it is to create a new nested content model with one date field, and then include these single date entries as a reference list. The issue with this approach is that the date is not showing as the entry title. Instead, a list of dates is only displayed as a list of blocks all labeled "Untitled", which is very unintuitive, as shown in the following screenshot.
Screenshot of the current status
So the questions are: Is there a good way to display the date as Entry title, or is there another solution to include a list of dates into the content model?
I am investigating the use of UI Extensions to solve this, but maybe there is a simpler build-in solution to the problem, than a custom developed extension.
You can't specify the Entry title from date fields, but rather only from short or long text fields, so a UI extension would be the way to go. Add a short text field called title (and specify that this field represents the entry title) then create a UI extension which will put a string of the selected date from the date field into the title field. Check out https://github.com/contentful/extensions/tree/master/samples/slug for a good starting point.

Use list filter value when adding new items to list

In a webpart page I got a list that is filtered on a value given from another webpart.
When adding an item to that list (from this webpart page); is there a way to preset the column the list is filtered on to be the same as the filter value?
Thanks.
Ivar
this link describes how to pre-fill field based on a query string variable. It can be useful for you, and if you add some modification to this solution your problem should be solved. The thing is that when you come to the part where you create the parameter for the "New item form" web part, you'll not specify to be a query string parameter. Instead it should be of type "None", and after that when you make the connections between the webparts you'll connect them in a way that they pass parameters to each other, not filters. I had some similar problem recently and made it work out in this way.

Resources