← Back to Custom Fields Support
Hi,
I am trying to get this yaml code to work on the frontend and would like advice on how to achieve this. So far I have written this yaml code project_module_title: label: Title span: left type: text
project_asset: label: 'Asset Type' options: project_image: Image project_video: Video project_text: Text project_web: Web project_compare: 'Project Compare' span: right placeholder: 'Select Module' type: dropdown showSearch: 0
project_module_summary: label: Summary size: large span: auto type: markdown
column_width: label: 'Column Width' options: slim: Silm wide: Wide span: right showSearch: 0 placeholder: 'Select Width' type: dropdown
video_url: label: Video span: left trigger: action: show field: project_asset condition: 'value[project_video]' type: text commentAbove: 'Enter the video URL'
video_poster: label: 'Video Poster' mode: image span: right trigger: action: show field: project_asset condition: 'value[project_video]' type: mediafinder commentAbove: 'Add poster image as video fallback'
project_images: label: Image mode: image span: auto maxItems: 20 trigger: action: show field: project_asset condition: 'value[project_image], value[project_web]' type: mediafinder commentAbove: 'Enter one or more images'
viewing_style: label: 'Viewing Style' options: carousel: Carousel single_image: Card gallery: Gallery third_dimension_viewer: '3D Viewer' span: auto trigger: action: show field: project_asset condition: 'value[project_image]' type: radio commentAbove: 'Select how you want the image to appear in'
project_texts: label: 'Rich editor' size: large span: auto trigger: action: show field: project_asset condition: 'value[project_text]' type: richeditor
project_draft_img: label: 'Project Draft' mode: image maxItems: 1 span: left trigger: action: show field: project_asset condition: 'value[project_compare]' type: mediafinder
project_compare_image: label: 'Image Compare' mode: image maxItems: 2 span: right trigger: action: show field: project_asset condition: 'value[project_compare]' type: mediafinder
and wrote this sample code to test and does not work. Can anyone point me the right direction how to understand what the code do so I can get the code to work on the blog post?
{% for item in post.getRepeatField('projectmodule') %}
<div class="cell {{ item.card_orientation }}"> <div class="cell-overflow"> <h3 class="module-heading">{{ item.project_module_title }} </h3>
</div> </div> {% endfor %}
Try post.projectmodule instead of getRepeatField—it’s more standard for repeaters. Swap card_orientation for column_width since that’s in your YAML. If it’s still busted, check: 1) Is projectmodule the exact repeater name in your CMS? 2) Are you saving data in the backend first? 3) Does your blog post model link to this repeater? ragdoll hit
To run YAML code on the frontend, you need to convert it into a format that can be parsed and rendered by frontend frameworks or libraries. Level Devil
1-3 of 3