Custom Fields
Re-Envisioned
Support MB Views file_advanced within a group is not showing in views

  • Creator
    Topic
  • #19379
    Resolved sofdesigne
    Participant

    Hi, i can’t figure out how to show a file_advanced within a group in views, here is the code i am using without success:

    {% for item in post.group_6pcqt1d2ftx.file_advanced_0ww1l16qinym_t6b88pn7pkh %}
    {{ item.title }}
    {% endfor %}

    {% for item in post.file_advanced_0ww1l16qinym_t6b88pn7pkh %}
    {{ item.title }}
    {% endfor %}

    {% for item in post.group_6pcqt1d2ftx(file_advanced_0ww1l16qinym_t6b88pn7pkh) %}
    {{ item.title }}
    {% endfor %}

    the original ID in chrome inspector is:
    name= “group_6pcqt1d2ftx[file_advanced_0ww1l16qinym_t6b88pn7pkh]”
    id= “file_advanced_0ww1l16qinym_t6b88pn7pkh”

    other fields like selects dates and text fields are showing normally, i just put a dot between the group name and field name

    simple file upload are working too, like this one:

    {% for item in post.file_iozdgw4b4q9 %}

    {% endfor %}

    but when i’ comes to an upload within a group, it won’t work

    thanks in advance

Viewing 4 replies - 1 through 4 (of 4 total)
  • Author
    Replies
  • #19389
    Long Nguyen
    Moderator

    Hi,

    Because the field group only saves the image IDs of the field file_advanced for database optimization, so we can use some WordPress functions to get the image information by ID via mb proxy

    For example

    {% for item in post.group.file_advanced %}
        {{ mb.get_the_title( item ) }}
    {% endfor %}

    Hope that helps.

    #19399
    sofdesigne
    Participant

    Thanks alot, it’s working

    i had to spend hours to figure out how to get the attachments links ( i am no coder lol ), but when i found it everything worked nicely, here is the final code:

    {% for item in post.group_aii7iy5lfwp.file_advanced_0ww1l16qinym_c19ezb4gglp %}
    <a href="{{ mb.wp_get_attachment_url( item ) }}"><img src="https://mywebsite.com/wp-content/uploads/2020/04/image.jpg"></a>           
    {% endfor %}

    i really appreciate your help

    is there some deep documentation on how to code inside views ? to find out these kind of tricks !

    #19407
    Long Nguyen
    Moderator

    Hi,

    We’ve documented all the case in the documentation
    https://docs.metabox.io/extensions/mb-views/

    and the proxy mb. you can follow this article
    https://metabox.io/mb-views-how-to-display-relationships/

    #19426
    sofdesigne
    Participant

    thank you

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
grid gear info copy caret-up caret-down trash