首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >HubSpot中的两(2)栏博客布局

HubSpot中的两(2)栏博客布局
EN

Stack Overflow用户
提问于 2015-12-31 07:53:52
回答 1查看 548关注 0票数 0

我正在尽我最大的努力学习Hubspot的HubL语言和CSS,但我的博客被困在创建一个2列的格式上(他们只提供1列的格式)。我插入了他们的博客内容模块,然后编辑了"Listing Template“代码,使其更符合我的喜好,如下所示。在博客设置页面中,我将每个“列表页面”的帖子数量设置为10,但希望将其设置为5。

我还应用了这种内联样式,这样第一列就占据了一半的空间,这很好,但我不知道如何告诉它将帖子6-10换成另一列。我正在阅读我所能读到的关于如何让它工作的一切信息,但没有任何东西直接适用于我的问题。

代码语言:javascript
复制
max-width: 50%; height: auto;

警告-我可以编辑以下内容,我可以应用CSS样式,但这是我的知识范围。如果我必须在Javascript中做一些事情,我可以复制-粘贴到一个应用于站点的文件中,但仅此而已。

代码语言:javascript
复制
<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>

EN

回答 1

Stack Overflow用户

发布于 2016-01-03 00:39:10

您可以反转循环,并使用模块将帖子拆分为2列

将开始循环更改为:

代码语言:javascript
复制
<div class="span5">{% for content in contents|reverse %}

然后将循环的闭合更改为:

代码语言:javascript
复制
   {% if loop.index % 5 == 0 %}
     </div><div class="span5">
   {% endif %}
 {% endfor %}
 </div> <!-- close the span5 we opened -->
</div> <!-- close the parent loop container -->
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34539067

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档