October CMS How to replace component templates from plugins

How can you replace component templates from plugins? IE I want to replace the posts default template in the blog plugin with my own markup. Post List from the blog plugin

— Edit —

Use the override of a template instead. https://octobercms.com/docs/cms/components#overriding-partials

— Old way —

Turns out it is easy, just copy and paste in to your own partial. I typically name mine prefixed with the plug-in. “blog-plugin/post-list.htm”

Then just modify to your specs and insert in the page.


{% component 'blogPosts' %}


{% partial 'blog-plugin/posts-list.htm' %}

See the comments below for other solutions. In the docs it notes that you can override the partial that is used.

October CMS set preview post length

October CMS is a brilliant new developer focused CMS. It reminds me of working on XenForo in it’s ease of creating add-ons. A very nice system.

After configuring the blog I needed to limit the post except size for post that didn’t have an except. This meant shrinking the normal content on category list view and post list view. It turned out to be simple.

First open both the blog list template and category list template. Find the code tab and click it.

Then add this:

function onEnd()
    if (isset($this['posts']))
        foreach($this['posts'] as &$post) {
            $post->content_html = wordwrap($post->content_html, 250);
            $post->content_html = explode("\n", $post->content_html);
            $post->content_html = $post->content_html[0] . '...';

Before is display it’ll be parsed and limited. The code is a bit of code that I modified from SO. I’d link back but can’t find the source thread anymore.