This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

markandmedia
markandmedia

I'm currently exploring the snippet functionality created in a Partial. I have created a property with the dropdown option and everything seems to be working as expected in the Pages plugin. The "client" can insert the snippet in the page and make a selection from the list. This is saved as expected (Using the ID). What I can't seem to figure out is how to get the value. When I use {{ itemBlokIcoon }} it gives me the selected ID. How can I ask for the value associated with the selected ID?

An example below, the saved value could be the 3th one, what twig code can I use to get the associated value "fa-plane". (The page now shows "2" where I expected "fa-plane".

description = "Item voor op de homepagina"

[viewBag]
snippetCode = "home-item"
snippetName = "home-item"
snippetProperties[itemBlokTitel|type] = "string"
snippetProperties[itemBlokTitel|title] = "item-blok-titel"
snippetProperties[itemBlokTitel|default] = "Titel item"
snippetProperties[itmBlokTekst|type] = "string"
snippetProperties[itmBlokTekst|title] = "item-blok-tekst"
snippetProperties[itmBlokTekst|default] = "Sed ut perspiciatis unde omnis iste natus sit voluptatem"
snippetProperties[itemBlokIcoon|type] = "dropdown"
snippetProperties[itemBlokIcoon|title] = "item-blok-icoon"
snippetProperties[itemBlokIcoon|default] = "fa-lightbulb-o"
snippetProperties[itemBlokIcoon|options|0] = "fa-lightbulb-o"
snippetProperties[itemBlokIcoon|options|1] = "fa fa-image"
snippetProperties[itemBlokIcoon|options|2] = "fa-plane"
snippetProperties[itemBlokIcoon|options|3] = "fa-cog"
snippetProperties[itemBlokIcoon|options|4] = "fa-html5"
snippetProperties[itemBlokIcoon|options|5] = "fa-twitter"

[staticPage]
==

 TEST: {{ itemBlokIcoon }}

Last updated

jonathan
jonathan

I have the same issue. I need to get both the key and value of the select. Is that even possible? Thanks!

joshwordshop51728
joshwordshop51728

I know this is dead old but I got stuck too so worth answering it

I wrote it out like this and it seems to work fine

snippetProperties[botButtonColor][title] = "Bottom Button Color"
snippetProperties[botButtonColor][type] = "dropdown"
snippetProperties[botButtonColor][default] = "red"
snippetProperties[botButtonColor][options]['red'] = "red"
snippetProperties[botButtonColor][options]['white'] = "white"

1-3 of 3

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.