0

I'm doing my best to learn Hubspot's HubL language and CSS but am stuck on creating a 2 column format for my blog (they only provide a 1 column format). I inserted their Blog Content module, then edited the "Listing Template" code to be more to my liking, as follows. In the blog settings page I set the number of posts per "listing page" to 10 but would like to make it wrap at 5.

I also applied this inline styling so that the first column takes up half the space, which is good, but can't figure out how to tell it to wrap posts 6-10 to another column. I am reading everything I can about how I can get this to work but nothing applies directly to my problem.

max-width: 50%; height: auto;

Caveat - I can edit the below and I can apply CSS styling but that's the extent of my knowledge. If I have to do something in Javascript, I can copy-paste into a file that applies to the site but that's about it.

<div class="blog-section">
<div class="blog-listing-wrapper cell-wrapper">
            <div class="blog-section">
        <div class="blog-listing-wrapper cell-wrapper">
    {# simple_list_page indicates the "blog/all" page, which is a list of links to every blog post #}
            <div class="post-listing{% if simple_list_page %}-simple{% endif %}">
                {% if blog_author %}
                    <div class="hs-author-profile">
                        <h2 class="hs-author-name">{{ blog_author.display_name }}</h2>
                        {% if blog_author.avatar %} <div class="hs-author-avatar"> <img src="{{ blog_author.avatar }}" alt="{{ blog_author.display_name }}"> </div> {% endif %}
                        <div class="hs-author-bio">{{ blog_author.bio }}</div>
                        {% if blog_author.has_social_profiles %}
                            <div class="hs-author-social-section">
                                <span class="hs-author-social-label">Find me on:</span>
                                <div class="hs-author-social-links">
                                    {% if blog_author.facebook %}
                                        <a href="{{ blog_author.facebook }}" target="_blank" class="hs-author-social-link hs-social-facebook">&nbsp;</a>
                                    {% endif %}
                                    {% if blog_author.linkedin %}
                                        <a href="{{ blog_author.linkedin }}" target="_blank" class="hs-author-social-link hs-social-linkedin">&nbsp;</a>
                                    {% endif %}
                                    {% if blog_author.twitter %}
                                        <a href="{{ blog_author.twitter }}" target="_blank" class="hs-author-social-link hs-social-twitter">&nbsp;</a>
                                    {% endif %}
                                    {% if blog_author.google_plus %}
                                        <a href="{{ blog_author.google_plus }}?rel=author" target="_blank" class="hs-author-social-link hs-social-google-plus">&nbsp;</a>
                                    {% endif %}
                                </div>
                            </div>
                        {% endif %}
                    </div>
                    <h3 class="hs-author-listing-header">Recent Posts</h3>
                {% endif %}
                {% for content in contents %}
                    <div class="post-item">
                        {% if not simple_list_page %}

                        {% if topic %}<h3>Posts about {{ page_meta.html_title|replace(' | ', '') }}</h3>{% endif %}

                            {% if content.topic_list %}
                                 <p id="hubspot-topic_data"> >
                                    {% for topic in content.topic_list %}
                                        <a class="topic-link" href="{{ group.absolute_url }}/topic/{{ topic.slug }}">{{ topic.name }}</a>{% if not loop.last %},{% endif %}
                                    {% endfor %}
                                 </p>
                            {% endif %}

                            {{ content.publish_date_localized }}
                            <div class="post-header">
                                <h2><a href="{{content.absolute_url}}">{{ content.name }}</a></h2>
                            </div>
                            <div class="post-body clearfix">
                                <!--post summary-->

                                {% if content.post_list_summary_featured_image %}
                                    <div class="hs-featured-image-wrapper">
                                        <a href="{{content.absolute_url}}" title="" class="hs-featured-image-link">
                                            <img src="{{ content.post_list_summary_featured_image }}" class="hs-featured-image">
                                        </a>
                                    </div>
                                {% endif %}

                                {{ content.post_list_content|safe }}

                                {% if content_group.show_summary_in_listing %}
                                <a class="more-link" href="{{ content.absolute_url }}">Read More</a>
                                {% endif %}                                    
                            </div>
                        {% else %}
                            <h2 class="post-listing-simple"><a href="{{content.absolute_url}}">{{ content.name }}</a></h2>
                        {% endif %}
                    </div>
                {% endfor %}
            </div>

            {% if not simple_list_page %}
            <div class="blog-pagination">
                {% if last_page_num %}
                    <a class="previous-posts-link" href="{{ blog_page_link(last_page_num) }}">Previous</a>
                {% endif %}
                    <a class="all-posts-link" href="{{ group.absolute_url }}/all">All posts</a>
                {% if next_page_num %}
                    <a class="next-posts-link" href="{{ blog_page_link(next_page_num) }}">Next</a>
                {% endif %}
            </div>
            {% endif %}
        </div>
    </div>

</div>

Rebekah Paul
  • 59
  • 1
  • 4

1 Answers1

0

You could reverse the loop and use modulus to split the posts into 2 columns

change your opening loop to:

<div class="span5">{% for content in contents|reverse %}

and then change the closing of the loop to:

   {% if loop.index % 5 == 0 %}
     </div><div class="span5">
   {% endif %}
 {% endfor %}
 </div> <!-- close the span5 we opened -->
</div> <!-- close the parent loop container -->
Tim Joyce
  • 4,487
  • 5
  • 34
  • 50