Custom Fields
Re-Envisioned
Support MB Views Display multiple media files connected to a user

  • Creator
    Topic
  • #22208
    Resolved Henri
    Participant

    Hi,

    I’ve extended the User with an File Advanced field in which I connect multiple Media files from the library to the user. Now I would like to show that on a page, so I thought to use MB views for that. I’ve added the following code:

    
    {{ user.first_name }} {{ user.last_name }}
    <ul>
    {% for post in query.posts %}
    <li>{{ user.downloaded_files }}</li>
    {% endfor %}
    </ul>
    

    The first and last name are being displayed. However, for the downloaded_files it shows ‘array’. It has 2 connected files, so I understand that it is an array, but how do I need to change the code so that the files are shown? Or is this not the way to accomplish my use case?

    Kind regards, Henri

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

    Hi,

    Because the field file_advanced always returns an array when retrieving so we have to loop through the array to get items information. Here is the sample code:

    {% for item in user.downloaded_files %}
        {{ item.title }}
    {% endfor %}

    You can also click to Insert Field > Users > Custom Fields > File Advanced, to generate the code automatically. See https://share.getcloudapp.com/OAuJEWm1.

    For more information, please follow the documentation https://docs.metabox.io/fields/file-advanced/#template-usage.

    #22217
    Henri
    Participant

    Hi Long Nguyen,

    Awesome, it works like a charm now. I finally found a way to do what I want with your plugin 😊 I’ve tried it with Pods and with ACF in combination with Beaver Themer and it didn’t work. Now I’m able to it with just Metabox. Awesome 👍🏻

    Kind regards, Henri

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.