Photo of Blake Anglin

0

Connection Type

If I wanted to create a block on our website that uses lava to pull the connections opportunities from a connection type how would the lava code look. 

For each opportunity i want it to create a card the displays the title, Details and image that you can add in the connection Opportunity Detail and when you click on it it sends you to the connection form affiliated with that connection opportunity. 

  • Photo of Michael Allen

    0

    The easiest option is to use the "Connection Opportunity Search" block. You don't have to show any of the filter options if you don't want them.

    Here is the lava that I am using on my site with that block to display the opportunities in a card layout. I'm not showing the picture, but you could add that with {{ opp.PhotoUrl }}.

    {% raw %}
        {% assign numOpps = Opportunities | Size %}
    {% unless numOpps > 0 %}
    <h3>No teams were found matching that criteria.</h3>
    {% else %}
        {% assign Opportunities = Opportunities | Shuffle %}
    <div class="row d-flex flex-wrap">
        {% for opp in Opportunities %}
            {% assign hasParagraphTag = opp.Summary | RegExMatch:'^<p>' %}
            {% assign isPublic = opp | Attribute:'Public','RawValue' | AsBoolean %}
            {% unless isPublic %}{% continue %}{% endunless %}
        <div class="col-md-4 col-sm-6 mb-4">
            <div class="card h-100">
                <div class="card-body">
                    <h3 class="card-title text-center">{{ opp.PublicName }}</h3>
            {% if hasParagraphTag %}
                        {{ opp.Summary | Trim }}
            {% else %}
                        <p>{{ opp.Summary | Trim }}</p>
            {% endif %}
                </div>
                <div class="card-footer text-center">
                {% if DetailPage and DetailPage != '' -%}
                    {% if DetailPage contains '?' -%}
                    <a class='btn btn-primary' href='{{ DetailPage }}&OpportunityId={{ opp.Id }}'>Join Team</a>
                    {% else -%}
                    <a class='btn btn-primary' href='{{ DetailPage }}?OpportunityId={{ opp.Id }}'>Join Team</a>
                    {% endif -%}
                {% endif %}
                </div>
            </div>
        </div>
        {% endfor %}
    </div>
    {% endunless %}
    {% endraw %}