Include an iframe in blog post content without embed.ly
I'd like to embed this page as an iframe in my blog post content, but I want it to show up before the flip in the generic 'blog' page, ie showing the N most recent posts.
If someone clicks through, I can show them the iframe by editing the template for that particular blog post - but for the most recent blog posts page, the iframe needs to come out of post.blog_post.content but the HTML editor consumes it.
I thought about editing the overall blog template to look at the tag of each post, and use a special tag to know to show the extended version in the list, but I can't think of where I'd put the URL of the iframe I want to show, unless I hijack another tag and use the tag.name field to hold it.
I think it'd be really nice to be able to tell the editor to not strip the iframe, and to just trust me when I tell it I know what I'm doing.
Showing 1 reaction
What I’m doing is using tags as ht-key-value (ht stands for “hack tags”). I changed theme-wide _page_tags.html to ignore tags that start with ht-:
{% if page_tags.tags_count > 0 }
{ for tag in page_tags.tags }
{ unless tag.name contains “ht-” }
{{ tag.name }}
{ endunless }
{ endfor %}
{% endif %}
and then, for my “Endorsed Candidate” blog, on each candidate post I tagged them as ‘ht-office-District 1’ and ‘ht-office-District 2’, etc. When you look at the post, that tag no longer shows up.
On the blog post listings page, I added some code to the template (only for that page, not the theme-wide template):
{% for post in page.blog.most_recent_blog_posts %}
{{ post.headline }}
{% if post.tags_count > 0 %}{% for tag in post.tags }
{ if tag.name contains “ht-office” }
{{tag.name | split:“-” | last}}
{ endif }
{ endfor }
{ endif %}
It’s a little wonky, but it’s a start.