Códigos Hubl Hubspot Post y Blog

Post - Artículo

Link

{{ content.absolute_url }} 

Título

{{ content.name }} 

Descripción

{{ content.post_body }} 

Imagen

{% if content.featured_image %}
    <img src="{{ content.featured_image }}" alt="{{ content.name|safe|striptags }}">
{% endif %} 

Autor

{{ content.blog_post_author.avatar }}
{{ content.blog_post_author.display_name }}
{{ content.blog_post_author.bio }} 

Todos los tags ó categorías

{% if content.tag_list %}
   {% for tag in content.tag_list %}
        <a href="{{ blog_tag_url(group.id, tag.slug) }}">{{ tag.name }}</a>{% if not loop.last %},{% endif %}
    {% endfor %}
{% endif %} 

Solo 1 tag ó categoría

{% if content.tag_list %}
   {% for tag in content.tag_list %}
   {% if loop.index == 1 %}
        <a href="{{ blog_tag_url(group.id, tag.slug) }}">{{ tag.name }}</a>{% if not loop.last %}{% endif %}
    {% endif %}
    {% endfor %}
{% endif %} 

Link de categoría

{{ blog_tag_url('default', 'categoria-post') }} 
{{content.publish_date|datetimeformat('%B %e %Y') }}
{{content.publish_date|datetimeformat('%d/%m/%Y') }}
//enero 20, 2020
{{content.publish_date|datetimeformat('%B %e,%Y') }} 

Tiempo de lectura en minutos

{% if content.post_body|wordcount > 0 %}{{content.post_body|wordcount|float|divide(300)|round(0, 'ceil')}}{% else %}1{% endif %} min 

Artículos recientes

Recientes

{% set rec_posts = blog_recent_posts('default', 5) %}
{% for rec_post in rec_posts %}
    {{ rec_post.absolute_url }}
    {{ rec_post.featured_image }}
    {{ rec_post.name }}
    {{ rec_post.post_summary|striptags|truncate(150, breakword=False, end='...') }}
    {{ rec_post.blog_post_author.avatar }}
    {{ rec_post.blog_post_author.display_name }}
    {{ rec_post.blog_post_author.bio }}
    {{ rec_post.tag_list[0] }}
{% endfor %} 

Recientes

{% set topic_posts = blog_recent_topic_posts('default', 'optimization', 4) %}
      {% for topic_post in topic_posts %} 
          {{ topic_post.absolute_url }}
          {{ topic_post.featured_image }}
          {{ topic_post.name }}
          {{ topic_post.post_summary|striptags|truncate(150, breakword=False, end='...') }}
          {{ topic_post.absolute_url }}
          {{ topic_post.tag_list[0] }}
      {% endfor %} 

Artículos relacionados

3 artículos relacionados

{% macro blog_post_formatter(post) %}
    {% for topic in post.topic_list %}{{ topic.slug }}{% if not loop.last %} {% endif %} {% endfor %}
            {{ post.tag_list[0] }}
            {{ post.absolute_url }}
            {{ post.featured_image }}
            {{ post.name }}
            {{ post.publish_date|datetimeformat('%B %e, %Y') }}
{% endmacro %}

{% set post_tags = content.tagList|join(", ")|replace(' ', '-')|lower %}
{% related_blog_posts limit=3, tags="{{ post_tags }}" post_formatter="blog_post_formatter" %} 

3 artículos relacionados, modo 2

{% set post_tags = content.tagList|join(", ")|replace(' ', '-')|lower %}
  
  {% set topic_posts = blog_recent_tag_posts('default', post_tags, 3) %}
  
  {% if topic_posts|list|length == 0 %}
        {% set topic_posts = blog_recent_posts('default', 3) %}
  {% endif %}
  
  {% for post in topic_posts %} 
  
        {% for topic in post.topic_list %}{{ topic.slug }}{% if not loop.last %} {% endif %} {% endfor %}
        {{ post.tag_list[0] }}
        {{ post.absolute_url }}
        {{ post.featured_image }}
        {{ post.name }}
        {{ post.publish_date|datetimeformat('%B %e, %Y') }}
{% endfor %}  

Blog - Lista de artículos

 {% for content in contents %}
    <div class="post-item">
        {{ content.tag_list[0] }}
        {{ content.absolute_url }}
          {{ content.featured_image }}
          {{ content.name }}
          {{ content.post_summary|striptags|truncate(150, breakword=False, end='...') }}
          {{ content.absolute_url }}
    </div>
{% endfor %} 

Blog - Lista - Incluir una imagen personalizada

Campo personalizado para mostrar imagen en lista
 {#Agregar en post #}
 {% image_src 'custom_listing_image' widget_name='Custom Listing Image' label='Custom Listing Image 400*300', no_wrapper=True,export_to_template_context=True %}
 
 {#mostramos la imagen en la lista#}
 {% if content.widgets.custom_listing_image.body.src %}
     <img src="{{ content.widgets.custom_listing_image.body.src }}" alt="{{ content.name }}" />
{% else %}
    <img src="{{ content.featured_image }}" alt="{{ content.name }}" />
{% endif %} 

Blog - Más populares

{% set pop_posts = blog_popular_posts('default', 6) %}
{% for pop_post in pop_posts %}
    <div class="post-title">{{ pop_post.name }}</div>
{% endfor %} 

Listar todas las categorías - tags - topics

<ul>
 {% set my_topics = blog_topics('default', 250) %}
      {% for item in my_topics %}
      <li><a href="{{ blog_tag_url(group.id, item.slug) }}">{{ item }}</a></li>
      {% endfor %}
</ul> 
Share on facebook
Share on twitter
Share on linkedin