Team > Topic > Event in a View

Support MB Views Team > Topic > Event in a ViewResolved

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #47657
    swestswest
    Participant

    We are building a way to display the topics our team members present at speaking events.

    I have Custom Post Types for Team Members (team), Topics (topic), and Events (events)
    with the following Relationships:

    • Team to Topic (team-to-topic)
    • Topic to Event (topic-to-event

    One view of the data will be to display the Topics of an individual Team Member on the Single Team page.

    I have the view working except for one line where I want to display the related topic_datetime followed by the related event.name.
    The view displays everything correctly except for the event.name. Can you tell me what I am doing wrong?

    View: team-member-topic-view
    https://pastebin.com/C57JiN93

    The problem is in the second part of this div: <div class="topic-date-and-event-name">

    I've tried to annotate a screenshot of this view's output and where the problem lies. I can give you access to the staging site if that would help.
    https://share.cleanshot.com/s3gJjfz0

    I did see in this support post a solution for traversing multiple related CPTs: https://support.metabox.io/topic/traversing-multiple-related-cpts/

    I updated the view code for my custom post type configuration, but it returned fatal query normalizer errors.
    https://share.cleanshot.com/Hr6wjQQp

    Single Team Member Topics view:
    https://pastebin.com/f3WD9DXN

    Any help you can give will be appreciated.

    #47663
    PeterPeter
    Moderator

    Hello,

    Can you please also share the settings of 2 relationships?
    - Team to Topic (team-to-topic)
    - Topic to Event (topic-to-event)

    I check this View code https://pastebin.com/f3WD9DXN
    but don't see any issue when outputting topic and event posts.

    #47664
    swestswest
    Participant

    Topic to Team Relationship
    https://pastebin.com/yg9iBdYw

    Topic to Event Relationship
    https://pastebin.com/5wWAL2Wv

    I check this View code https://pastebin.com/f3WD9DXN
    but don't see any issue when outputting topic and event posts.

    Can I give you access to the staging site where I am seeing the fatal errors?

    #47666
    PeterPeter
    Moderator

    Hello,

    The relationship ID in the query args is wrong. This is the relationship settings:

    function your_prefix_function_name() {
        MB_Relationships_API::register( [
            'id'          => 'event-to-topic',

    this is the query args

    {% set topic_args = { relationship: { id: 'relationship-team-to-topic', from: post.ID }, nopaging: true, post_type: 'topic' } %}

    it should be event-to-topic, not relationship-team-to-topic. Where do you get this ID relationship-team-to-topic ?

    Here is the updated query args

    {% set topic_args = { relationship: { id: 'topic-to-team', to: post.ID }, nopaging: true, post_type: 'topic' } %}
    
    {% set event_args = { relationship: { id: 'event-to-topic', to: topic.ID }, nopaging: true, post_type: 'event' } %}

    Let me know if it helps.

    #47667
    swestswest
    Participant

    Thank you, that helped.

    In the View, how do I set an orderby?

    I tried:

    
    {% set topic_args = { relationship: { id: 'relationship-team-to-topic', from: post.ID }, nopaging: true, post_type: 'topic', orderby: '{ post.topic_datetime | date( 'Y-m-d H:i' ) }', order: 'ASC' } %}
    

    but it resulted in fatal errors.

    #47668
    PeterPeter
    Moderator

    Hello,

    If you use the variable, you should remove the curly brackets and single quote from the query arg:

    {% set topic_args = { 
    relationship: { id: 'relationship-team-to-topic', from: post.ID }, 
    nopaging: true, 
    post_type: 'topic', 
    orderby: post.topic_datetime | date( 'Y-m-d H:i' ), 
    order: 'ASC' } 
    %}
    
    #47669
    swestswest
    Participant

    That worked great.
    Thank you very much for your help.

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