Support Forum » User Profile

Forum Replies Created

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • Silvia PalandriSilvia Palandri
    Participant

    If possible I would like to get to the bottom of this with your help, because it's in my opinion a crucial step on the path to learning to use METABOX to its full capacity.
    So I corrected all the errors you pointed out, double checking names and slugs.
    Recapping:
    Course Catalog Slug : corso
    Relationship Slug : sessione-corso-a-catalogo
    Course Session Slug : sessione-corso

    Now my view code is :

    {% set args = { post_type : "sessione-corso" , posts_per_page: -1, order : "DESC" } %}
    {% set posts = mb.get_posts (args) %}
    {% set currentDate = "now"|date("Y-m-d") %}

      {% for post in posts %}
      {# get the course catalog post #}
      {% set catalog_args = { post_type: 'corso', relationship: { id: 'sessione-corso-a-catalogo', to: post.ID } } %}
      {% set catalog_posts = mb.get_posts( catalog_args ) %}
      {% for catalog_post in catalog_posts %}
      {# get the catalog post image and other info #}
      {% set coverfoto = attribute( catalog_post, 'cover-corso' ) %}
      {% set duratacorso = attribute( catalog_post, 'durata-corso' ) %}
      {% endfor %}
      {# get the session course info #}
      {% set datapartenza = attribute( post, 'data-partenza-corso' ) %}
      {% set prezzo_associati = attribute( post, 'prezzo-associati' ) %}
      {% if datapartenza | date( 'Y-m-d' ) >= currentDate %}
      {# display the course card with data from both PARENT CORSO and SESSIONE CORSO #}
      <div class="container">
      <div class="cardcorso">
      <div class="imagecorso">


      <div class="badge">€ {{ prezzo_associati }},00</div>
      </div>
      <div>
      <h4>{{ post.title }}</h4>
      Data Partenza: {{ datapartenza | date( 'd-m-Y' ) }}
      {% set calendariocorso = attribute( post, 'calendario-corso' ) %}
      <h5>CALENDARIO CORSO</h5>

      {% for clone in calendariocorso %}

    • {{ clone | date( 'd-m-Y' ) }}
    • {% endfor %}

    <h5>DURATA CORSO</h5>
    <p>{{ duratacorso }}</p>
    </div>
    </div>
    </div>

    {% endif %}
    {% endfor%}

    Still it is not showing neither the "cover_corso" as image nor the duration of the course {{ duratacorso }}

    If I inspect the page I see this:
    html code where the image should be ->
    html code where the course duration should be=> <p></p>

    So it seems that the second query is not targeting anything. Please tell me what I am doing wrong
    or what should I check for errors.
    Thank you!

    Silvia PalandriSilvia Palandri
    Participant

    Please discard previous message, I hadn't seen that the code was right there.
    So this is the complete code, but it's still not working. Can you please point out any mistakes you see?

    {% set args =  { post_type : "sessione-corso" , posts_per_page: -1, order : "DESC" } %}
    {% set posts = mb.get_posts (args) %}
    {% set currentDate = "now"|date("Y-m-d") %}
    {% for post in posts %}
    
       
    
    {% endfor %}
    <ul>
    {% for post in posts %}
          {# get the course catalog post #}
        {% set catalog_args = { post_type: 'catalogo-corso', relationship: { id: 'sessione-corso-a-catalogo', to: post.ID } } %}
        {% set catalog_posts = mb.get_posts( catalog_args ) %}
        {% for catalog_post in catalog_posts %}
            {% set covercorso = attribute( post, 'cover-corso' ) %}
        {# get the catalog post image and other info #}
            
        {% endfor %}
        {% set field = attribute( post, 'data-partenza-corso' ) %}
        {% set prezzo_associati = attribute( post, 'prezzo-associati' ) %}
        {% if field | date( 'Y-m-d' ) >= currentDate %}
           <div class="container">
                <div class="cardcorso">
                    <div class="imagecorso">
                        <img src="{{ coverfoto.full_url }}" width="150" />
                        <div class="badge">€ {{ prezzo_associati }},00</div>
                    </div>
                    <div>
                        <h4>{{ post.title }}</h4>
                        Data Partenza:  <strong>{{ field | date( 'd-m-Y' ) }}</strong>
                        {% set field = attribute( post, 'calendario-corso' ) %}
                        <h5>CALENDARIO CORSO</h5>
                        <ul>
                            {% for clone in field %}
                            <li> {{ clone | date( 'd-m-Y' ) }}</li>
                            {% endfor %}
                        </ul>
                    </div>
                </div>
            </div>
            
        {% endif %}
    {% endfor%} 
    </ul>
    
    Silvia PalandriSilvia Palandri
    Participant

    Thanks for your help.
    Could you be more specific giving me an example of the syntax needed to get a field named "cover_corso" please? So I can adapt this to any field I need from the parent post.
    Thanks

    Silvia PalandriSilvia Palandri
    Participant

    Hello, thanks for answering.
    Yes I set it thru MB relationships extension.

    in reply to: Cannot Access my license #37007
    Silvia PalandriSilvia Palandri
    Participant

    My issue has been resolved, now I can access the license page all right. Thank you

Viewing 5 posts - 1 through 5 (of 5 total)