Q: Embed blog in comfy page?
mroach opened this issue · 4 comments
I've looked over the docs and code and I haven't found a way to embed blog posts into a CMS page. Is it possible? I'm looking for something functionally equivalent to:
<% Comfy::Blog::Blog.first.posts.where(is_published: true).limit(5).each do |p| %>
<article>
<h1><%= p.title %></h1>
<div><%= p.content %></h1>
</article>
<% end %>
Or Is there any way of creating code-driven snippets?
Take that code and put it in a partial somewhere. Then inside CMS page render it with {{cms:partial:path/to/your/partial}}
That's one of the ways you can do it.
Cool. That'll do nicely. Thanks for the help with this and the blog bug.
Is there any facility in comfy for registering template blocks? Such that the blog plugin could register the {{ comfy:blog:* }} namespace and expose similar functionality? Or any plugin or local code being able to register template placeholders like that? Something like...
class Custom < Comfy::Cms::ABaseCmsPlaceholdersClass
def current_date
Time.now.utc
end
end
And then {{ custom:current_date }}
If there's not yet but you think that would be a useful idea, I could take a crack at it and send a pull request if I manage it.
Yeah, you can define your own tags. See this as an example: https://github.com/comfy/comfortable-mexican-sofa/blob/master/lib/comfortable_mexican_sofa/tags/page_text.rb Tags have to start with {{ cms
or it won't be recognized as such.
It gets more complicated if you want to involve forms in the admin area, but it can be done as well.
Reworking tag system to be a bit more flexible in my next to-do.
Fantastic! This will sort me out nicely. Thanks, Oleg!