CMS Development

MNault
Contributor | Elite Partner
Contributor | Elite Partner

Text Link

SOLVE

This is the line from the body text of a blog feed module. I would like to add a link to the blog post from the words "Read More".  

 

          <p>{{ post.post_body|safe|striptags|truncate(130, true, '...READ MORE') }}</p>

 

Would I plug in this line?

<a href="{{ post.absolute_url }}">READ MORE</a>

 

Can someone help me? Or am I not providing enough of the code?

 

0 Upvotes
1 Accepted solution
jonchim
Solution
Guide | Diamond Partner
Guide | Diamond Partner

Text Link

SOLVE

Thanks, you should be able to just add that line like this right under post body preview

       </div>
        <p>{{ post.post_body|safe|striptags|truncate(130, true, '...') }}</p>
        <a href="{{ post.absolute_url }}">Read More</a> 
     </div>





Jon Chim
VP of Design & Development
Hypha HubSpot Development


check Did my post help answer your query? Help the Community by marking it as a solution

View solution in original post

13 Replies 13
jonchim
Guide | Diamond Partner
Guide | Diamond Partner

Text Link

SOLVE

@MNault, the code  @dennisedson works as well didn't see that content. but changing it to post. works saves a line of code!






Jon Chim
VP of Design & Development
Hypha HubSpot Development


check Did my post help answer your query? Help the Community by marking it as a solution
jonchim
Guide | Diamond Partner
Guide | Diamond Partner

Text Link

SOLVE

haha @dennisedson  😀 i like your solution more didn't realize you can include the a tags in there altogether.






Jon Chim
VP of Design & Development
Hypha HubSpot Development


check Did my post help answer your query? Help the Community by marking it as a solution
dennisedson
HubSpot Product Team
HubSpot Product Team

Text Link

SOLVE

oops!  @jonchim beat me to the punch!

0 Upvotes
dennisedson
HubSpot Product Team
HubSpot Product Team

Text Link

SOLVE

Hey @MNault 

Welcome to the Community!

That looks about right.  Easiest thing to do is test it!  Should be able to look at the live preview.

Not sure what the plans are for the READ MORE you have in the paragraph is.  Either will need to remove it or add make it look like this

<p>{{ content.post_body|safe|striptags|truncate(130, true, ' <a href="{{ content.absolute_url }}">...READ MORE</a>') }} </p>
MNault
Contributor | Elite Partner
Contributor | Elite Partner

Text Link

SOLVE

Hmmm, I added that to the line of code and the entire blog body text disapeared. This is the live page, you can see the three blog posts. There are ellipsis at the end of each and we want to add READ MORE which then links the entire blog post. 

https://info.redpathcpas.com/construction-real-estate-and-engineering

 

0 Upvotes
jonchim
Guide | Diamond Partner
Guide | Diamond Partner

Text Link

SOLVE

Interesting, can you copy the code you have that is within the "blog-item-post" class so we can take a closer look?






Jon Chim
VP of Design & Development
Hypha HubSpot Development


check Did my post help answer your query? Help the Community by marking it as a solution
0 Upvotes
MNault
Contributor | Elite Partner
Contributor | Elite Partner

Text Link

SOLVE

        <div class="blog-item-post">

          <h3><a href="{{ post.absolute_url }}">{{ post.name }}</a></h3>

          <div class="blog-item-meta {{ 'margin-bottom' if post.post_body }}">

            <span class="author-icon">

              {% icon

                name="{{ module.blog_item_style.icons.author.name }}"

                style="{{ module.blog_item_style.icons.author.type }}"

                unicode="{{ module.blog_item_style.icons.author.unicode }}"

              %}

            </span>

            <a href="https://{{ post.parent_blog.url_base }}{{ '/author/'~post.blog_author.slug }}" class="blog-author">{{ post.blog_author }}</a>

            <span class="date-posted">

              <span class="date-icon">

                {% icon

                name="{{ module.blog_item_style.icons.date_icon.name }}"

                style="{{ module.blog_item_style.icons.date_icon.type }}"

                unicode="{{ module.blog_item_style.icons.date_icon.unicode }}"

              %}

              </span>

              {{ post.created|datetimeformat("%B %e, %Y") }}</span>

            {% if module.blog_list_settings.tag_style_settings.show_tag_in_blog_feed %}

            {% if post.topic_list %}

            <p class="hubspot-topic_data">

              {% for topic in post.topic_list %}

              <a class="topic-link" href="{{ blog_tag_url(group.id, topic.slug) }}">{{ topic.name }}</a>

              {% endfor %}

            </p>

            {% endif %}

            {% endif %}

          </div>

          <p>{{ post.post_body|safe|striptags|truncate(130, true, '...') }}</p>

        </div>

      </div>

    </div>

0 Upvotes
dennisedson
HubSpot Product Team
HubSpot Product Team

Text Link

SOLVE

If you were inputing my code snippet directly, replace content with post (apologies for that!)

0 Upvotes
jonchim
Solution
Guide | Diamond Partner
Guide | Diamond Partner

Text Link

SOLVE

Thanks, you should be able to just add that line like this right under post body preview

       </div>
        <p>{{ post.post_body|safe|striptags|truncate(130, true, '...') }}</p>
        <a href="{{ post.absolute_url }}">Read More</a> 
     </div>





Jon Chim
VP of Design & Development
Hypha HubSpot Development


check Did my post help answer your query? Help the Community by marking it as a solution
MNault
Contributor | Elite Partner
Contributor | Elite Partner

Text Link

SOLVE

Actually, I was hoping it would link to the appropriate full blog post but it just returns to the same page.

0 Upvotes
dennisedson
HubSpot Product Team
HubSpot Product Team

Text Link

SOLVE

hey @MNault 

Can you confirm that you updated this line

<p>{{ post.post_body|safe|striptags|truncate(130, true, ' <a href="{{ content.absolute_url }}">...READ MORE</a>') }} </p>

to make it be

<p>{{ post.post_body|safe|striptags|truncate(130, true, ' <a href="{{ post.absolute_url }}">...READ MORE</a>') }} </p>
MNault
Contributor | Elite Partner
Contributor | Elite Partner

Text Link

SOLVE

Ooops, sorry, I missed the second "post" - It works brilliantly now! THank you so much @dennisedson  and @jonchim  I appreciate this so much!!

jonchim
Guide | Diamond Partner
Guide | Diamond Partner

Text Link

SOLVE

Hey @MNault,

 

Yes I believe that line of code should work, you may have to remove the Read More part in the above <p> tags so it doesn't get repeated.






Jon Chim
VP of Design & Development
Hypha HubSpot Development


check Did my post help answer your query? Help the Community by marking it as a solution