How to call a item inside a field into another field - YAML TWIG


I’m trying to call a item inside a field into another field from Twig template, because I want to filter with expresions “If … Endif” for show or not a content. My blueprint file is this:

type: default
context: blueprints://pages

        type: tabs
        active: 1
                type: tab
                        type: list
                        style: vertical
                        label: BOOTSTRAP_BLOG.ADMIN.ITEM.INTERES
                        help: BOOTSTRAP_BLOG.ADMIN.ITEM.INTERES_HELP
                        collapsed: true
                                type: pagemediaselect
                                label: BOOTSTRAP_BLOG.ADMIN.INTERES_ICON
                                type: text
                                label: BOOTSTRAP_BLOG.ADMIN.INTERES_LINK
                                help: BOOTSTRAP_BLOG.ADMIN.INTERES_LINK_HELP
                                type: text
                                label: BOOTSTRAP_BLOG.ADMIN.INTERES_TEXT
                                type: text
                                label: BOOTSTRAP_BLOG.ADMIN.INTERES_DESCRIPTION
                                type: link
                                label: BOOTSTRAP_BLOG.ADMIN.VIDEOS_INTERES_URL
                                type: text
                                label: BOOTSTRAP_BLOG.ADMIN.VIDEOS_INTERES_URL_TEXT
                                type: text
                                label: BOOTSTRAP_BLOG.ADMIN.VIDEOS_INTERES_DESCRIPTION

And the code fragment where I want to call that field is this:

{% for card in %}
                        <p class="card-text"><img src="{{[card.icon].url}}"><strong>
                        <a href="{{ card.ruta }}" class="text-primary" target="_blank"> {{card.text}}</a></strong><br>{{card.description}}</p>

                        {% if %}
                                <div class="col-md-8 col-sm-12 col-12">
                                    <div class="embed-responsive embed-responsive-16by9">
                                        <iframe src="{{card.url_video}}" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
                                {% if %}
                                    <p class="card-text"><strong>{{card.description_video}} <a href="{{card.url_video}}" class="text-primary" target="_blank">{{card.url_text_video}}</a>) </strong></p>
                                {% endif %}
                        {% endif %}
                    {% endfor %}

At the moment I could not get to call that item from the twig template. The item is url_video.

I hope you can help me. Thank you


First, the answer:

After cutting down to the bare essentials, you have the following template:

{% for card in %}
   {% if %}  <-- Not getting right value
      {% if %} <-- Not getting right value
      {% endif %}
   {% endif %}
{% endfor %}

and the following frontmater:

    ruta: 'a link'
    text: 'some text'
    description: 'a description'
    url_video: url-to-video
    url_text_video: video-url-text
    description_video: video-description

Inside your template you ‘loop’ over the array of cards available in the frontmatter. To access the value of a single card, you should use card.url_video not

Second, a kind request: Please help the reader help you…

You could help the reader by:

  • Using a meaningful title.
    E.g.: “In Twig, I don’t get proper value of frontmatter”
  • Using a clear and concise description.
    E.g. “The variable ‘xyz’ in the following Twig snippet does not seem to return the correct value. The frontmatter is defined as follows …”
  • Showing only relevant data:
    • The blueprint has no relevance to the issue, only the frontmatter does.
    • Cut down code snippets to the essential part.
    • Indicate where to problem seems to occur.
  • Format snippets correctly

First of all, thank you very much for your help. And secondly, I am starting to use this forum and I totally agree with your opinions about my post.
I hope next time I will do better.
Again, thank you so much.