I have a custom blueprint that allows the user to create content in the backend with a I followed this guide, but how do I get the value created in the blueprint without reimplementing in my template?
I only get “default” or “folder” where I would want “PLUGIN_ADMIN.DEFAULT_ORDERING_DEFAULT”, “PLUGIN_ADMIN.DEFAULT_ORDERING_FOLDER” when calling the variable in my template. in the grav admin it shows the display text, so how can I pull this info from the blueprint in my template?
In my template I am calling the value similar to this:
{% for p in events %}
{{ p.header.sector }}
{% endfor %}
p.header.sector will give you “food” which is the actual value submited in the form, and saved in the content. However, the blueprint is where you define the display value. How can I get this display value back from the blueprint in the template?
I think what i want to do it somehow access the page blueprint from the template and get and object which includes an options array from which I can do a key lookup (?)
I assume in the blueprint I could just set the stored value and the display value the same, but I imagine this would be ideal for multilingual. I feel like its a good practice to store a simple value rather than the literal or that the key value should not have spaces?
You can use {{ dump(page.blueprints) }} (currently raising an exception, I fixed that in develop) to check all it contains, and then access a specific property of the form, for example (very long)
I have also tried accessing page.blueprints to find the headers. This does not seem to get me the blueprint I custom created in ../user/blueprints/pages/ None of the customer header.myfield values appear here. I would imagine that this blueprint should be associated with the page type. I tried dumping the entire {{ dump(page.blueprints) }}.
I realized my problem. I am display a list page.children() so I was returning the blueprint of the parent page, which is a different type than the children! It seems that {{ dump(page.children()|first.blueprints) }} is giving me the information that I want instead.
Is there a way to get the blueprint by specifying the blueprint manually e.g., something like
I had this issue, but just used the replace Twig function. Not ideal but I could not get anything else to work to correct it. This seemed the fastest way of getting around it at least.
header.property_type:
type: select
size: medium
classes: fancy
label: Property Type
options:
town_house: Town house
page.header.property_type|replace({'_': " "})
town_house the becomes town house
You could then use capitalize or title to further format the value
"town house"|capitalize > Town house
"town house"|title > Town House