This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

mickburkesnr
mickburkesnr

Hi everyone,

I want to show a list of blog posts, and just display the Title and publish date of the blog posts. However, at the moment, it also displays the content of the blog post.

How can I remove the blog content from being displayed on a blog post list? I don't want to rely on CSS, I'd like to remove it properly.

Thanks!

mickburkesnr
mickburkesnr

I managed to figure it out.

Deep within the bowels of the plugin, there's a file called default.htm. It's located here: plugins/rainlab/blog/components/posts.

This is the code:

        {% if post.excerpt %}
            <p class="excerpt">{{ post.excerpt }}</p>
        {% else %}
            <div class="content">{{ post.content_html|raw }}</div>
        {% endif %}

For my purposes, I've removed the {% else %} statement for the time being, but I will hope to do something fancy here that will allow the blog post list to be displayed without the content in some places, but then be visible in other places.

tekjava
tekjava

Now the question is... how can we modify this and keep it from reverting back to the old format when the plugin is updated...? I made changes to the post list page and the single post page... both reverted back when updating.

Goedda
Goedda

If you call the component like this

{% component 'blogPosts' %}

then the default markup will be used.

But if you call a partial instead

{% partial 'myOwnBlogPostsMarkup' %}

then the partial "myOwnBlogPostsMarkup.htm" from the /YourTheme/partials/ folder will be used. Please note that you will have to address the "post" variable differently there. You will need to address it like this

{{ blogPost.post }}

and consequently the "post.excerpt" like this

{{ blogPost.post.excerpt }}

It is all described here http://octobercms.com/docs/cms/components#moving-default-markup ;)

Last updated

tekjava
tekjava

Thank you @Goedda! Exactly what I needed to know! "moving default-markup to a partial"

Last updated

1-5 of 5

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.