CMS Development

victorwu
Participant

how to sort popular post by different blog ?

I wanna create a list included multi-blog posts and also sort out the most visited post in the top 5, how can I to do?截圖 2020-09-21 上午11.33.56.png do?

0 Upvotes
2 Replies 2
dennisedson
HubSpot Product Team
HubSpot Product Team

how to sort popular post by different blog ?

Hello @victorwu !

Although it looks like you have enough info in this screengrab, it would be beneficial to copy the code and use the code sample option so we can see all of the code.

 

HubSpot_Community_-_Reply_to_Message_-_HubSpot_Community.png

 

Also, if you could add the error message you are receiving on line 20.   

 

Going to tag a few people in on this to help

@Jake_Lett , @SandyG1 , @Anonymous --> could you all lend a hand?

 

Thanks!

d

victorwu
Participant

how to sort popular post by different blog ?

<div class="hs-rss-module feedreader_box custom-listing">
{% set popular_posts_one = blog_popular_posts(11653891338,2,"","popular_all_time") %}
{% set popular_posts_two = blog_popular_posts(11612398887,2,"","popular_all_time") %}
{% set popular_posts_three = blog_popular_posts(11914568457,2,"","popular_all_time") %}
{% set popular_posts_four = blog_popular_posts(18539513588,2,"","popular_all_time") %}
  {% set popular_posts_default = blog_popular_posts('default',2,"","popular_all_time") %}
  {% set all_content = content_by_ids([18539513588,11612398887,11914568457,18539513588]) %}
{% set my_blog_1 = blog_by_id(11653891338) %}
{% set my_blog_2 = blog_by_id(11612398887) %}
{% set my_blog_3 = blog_by_id(11914568457) %}
{% set my_blog_4 = blog_by_id(18539513588) %}
{% set popular_posts_all = (popular_posts_four + popular_posts_one + popular_posts_two + popular_posts_three)%}
{# {% set pop_posts = blog_popular_posts( 18539513588, 5,"","popular_all_time") %}   #}
  {% related_blog_posts blog_ids="11653891338,11612398887,11914568457,18539513588", limit=6, blog_authors="John Smith,Joe Smith,Frank Smith" %}
<div class="list-header">
    <h3>最多人瀏覽文章:</h3>
</div>
<ul class="list_block">
<!--  列表 -->
  {% for popular_post in popular_posts_all|sort('True', 'False', 'PageView') %}
{#   {% if loop.index < 5 %} #}
  <a href="{{ popular_post.absolute_url }}" class="hs-rss-title">
    <li class="list-tittle">
    <span>{{ popular_post.name }}/{{ popular_post.parent_blog.public_title }}</span>
    </li>
    </a>
  {#{% endif %}#}
{% endfor %}
</ul>
</div>
0 Upvotes