NationBuilder – Display Related Posts

NationBuilder Architect logo

NationBuilder is not WordPress, and has no built-in functionality to display related posts. That leaves certificate NationBuilder Architects (like we are at eddt inc.), Developers (yep, we do that too), and users alike looking for a solution.

This is the solution I’ve been using for a while over at www.conservativefutures.ca, which is a free market advocacy group in Canada.

It isn’t perfect, but I’ll explain how it works, and post an update here when I have the time to create a more elegant and permanent solution. Like many developers, I’ve been bogged down in other work.

This NationBuilder liquid code should be posted at the bottom of any type of page that you want to display related posts on. It can also be used in a sidebar.

// At the bottom of pages_show_blog_post.html

{% if page.tags_count > 0 %}
<div class=”related-posts”>
{% include “related_posts” with page %}
</div>
{% endif %}

As you can see, the snippet above checks to see if the page its on has any tags, and if so, applies a <div> tag with the class of “related-posts”. You can, of course, change that out for any other styles in your NationBuilder site.

Next, you need to create the _related_posts.html partial:

<section class=”news”>
{% for tag in page.tags %}
{% unless tag.name == ‘trending’ or tag.name == ‘homepage’ or tag.name == ‘campaign’ %}
{% for post in tag.most_recent_published_pages %}
{% if post.type_name == “Blog Post” %}
{% unless post.id == page.id %}
{% subpage post with “show_embedded_article” %}
{% endunless %}
{% endif %}
{% endfor %}
{% endunless %}
{% endfor %}
</section>

The first for statement loops through all the tags attached to the page.

Within the for statement, we use an unless statement to exclude some specific tags we use for other things in the NationBuilder theme template. You can edit this, or remove it as necessary.

Then we loop through the most_recent_published_pages, and if the post.type_name == “Blog Post” we use the _show_embedded_article.html partial to display the post, UNLESS, of course, it’s the very post that we’re looking at right now!

Here’s what we’ve used inside the _show_embedded_article.html partial:

<div class=”col-md-6 col-lg-6″>
<div class=”recent-news”>
<a href=”{{ post.url }}”><h3>{{ post.headline }}</h3></a>
<h5>{{ post.author.published_name }} — {{ post.published_at | date: ‘%B %d, %Y’ }}</h5>
<p>{{ post.blog_post.content | truncatewords: 15 | strip_html }} <a href=”{{ post.url }}”>[READ MORE]</a></p>
</div>
</div>

This is the partial that will really control what your related post looks like at the bottom of your blog_show_post page. Edit liberally.

As you can see, it’s not the most elegant solution, but it works to get NationBuilder displaying related posts just like WordPress.

The issue with this solution is that it may show a related post more than once, if the two blog posts share multiple tags. This is best used on a website where blog posts generally have only one tag, used much like a category.

Have any questions or comments? Leave them below. If you have a better solution, share!

Unbiased Canadian political news aggregator

Unfiltered Canadian Political News - cdnpolinews.ca

Need an aggregator for Canadian news? Stop searching for the best news app. You need look no further than cdnpolinews.ca.

That is, if what you’re looking for is political news.

If you are a news junkie, a politician, or a political staffer, you need a good political news aggregator. Until cdnpolinews.ca was launched, nobody had made a truly transparent, unbiased Canadian political news aggregator.

What is a Canadian political news aggregator?

A news aggregator is a website, or app, that takes content from across the web, and “aggregates” it into one place. What does this mean for you? It means that you don’t need to spend time looking at different news sites. You don’t need a tab open for CBC News, a tab for CTV News, a tab for the National Post, Financial Post, etc. It’s all in one place.

Why is cdnpolinews.ca good?

There are a few reasons. First of all, and maybe the most important, is that it’s truly unbiased. It’s unfiltered. And it’s transparent. How do I know? I made it. I publish the sources. With cdnpolinews.ca you know exactly where the news comes from. There are no hidden formulas or algorithms which promote certain content and bury other content. Every Canadian news story is displayed on the website in reverse-chronological order. The newest stories are posted at the top. The older stories are displayed at the bottom.

Are other news aggregators actually biased?

You tell me. Have you checked out National News Watch? Ever wondered why some stories stick in those coveted top display spots longer than others? Why do some stories on National News Watch get buried really fast? Or how an article starts to wander down the page but then shoots back up near the top?

I do.

I wonder about that all the time.

Does it happen automatically? Is someone doing it manually? Is it because of link clicks? Social shares?

The point is, we don’t know.

CDNPoliNews.ca is different, because you do know.

Can I get it in my social feeds?

You bet! @cdnpoli_news automatically tweets every time there is a new story. Ditto with posting to the Facebook page.

The site checks all the news feeds for new stories every 10 minutes. If it hasn’t blasted out more news, it’s because there isn’t any.

You can keep hitting refresh on the website if you want, or just browse Twitter and stay up to date.

Recap:

If you like getting up-to-the-minute Canadian political news, you should bookmark www.cdnpolinews.ca follow @cdnpoli_news on Twitter, and like the Facebook page.

I brewed beer

It’s a Hefeweizen. From a can, sure. Cooper’s wheat beer. I added a bag of dry wheat malt extract. 

It’s good. I’m going to make more. And I’ll post about the process. 

Wing Chung

I’ve just finished my second Wing Chun class.

My forearms are bruised, because I have no idea what I’m doing. 

Turns out, a 15 degree rotation of the wrist could’ve spared me a fair amount of pain!

But here’s the point:

Sifu Jerome of the Ottawa Wing Chun Academy is a seriously talented, and very nice guy. If anybody out there in internet-land wants to join, I highly recommend the club.

The Sifu had the opportunity to train directly under Grandmaster Ho Kam Ming. If you don’t know who that is, click the link. Seriously. He’s the real deal. 

Tuesdays and Thursdays, 7:30-9:00pm.

Now you know where to find me, stalkers!

(Better hurry, soon I’ll know Wing Chun)

5 Things to know to survive

I’m not a prepper, but I do want to be prepared. It’s important to me that I know the basic skills of survival for whatever scenario I might come across.

What really interests me is learning skills, because they’re portable.  What’s better than having a Swiss army knife? Being a Swiss army knife.

So what are the skills you should have to survive in case society collapses?

Here’s my basic list of survival skills:

  1. A martial art. It probably doesn’t matter which martial art you train in, but I’ve chosen Wing Chun. The thing is, you can have a great collection of knives, guns, or whatever, but that keeps you reliant on having knives or guns. You know what’s better than having a secret weapon? Being a secret weapon.
  2. How to make a fire without matches or a lighter. There are lots of techniques. The bow drill is common. It’s hard. But it works. What’s better than meeting your death on a cold and damp night? Knowing how to make fire.
  3. The basics of hunting. Snare traps are handy. So is knowing how to hunt with a rifle. How to field dress, and even how to butcher your game. You should probably also know that you can’t live off rabbit, because there’s not enough fat in the meat. What’s better than starving to death? Killing and eating food.
  4. How to find water, and make sure it’s safe to drink. Really, it’s very important. Being able to make fire and boil water is pretty handy too. You know what’s cooler than dying of dehydration? Having water.
  5. Know how to fly a plane. I’m not 100% on this one being a necessity, but I’m pretty sure that I want to be the guy who can get himself to the airport, hijack a bush plane, and take off into the bush to survive while everyone else is still trying to figure out whether there’s anything left in the grocery stores.

That’s my list. It’s far from complete, but I think it’s pretty good. To recap: learn to fight, make fire, hunt, find water, and fly a plane.

Oh, and you also might want some shelter.

Thoughts? I’d love to hear your must-have skills for the SHTF (Sh*t Hits The Fan) scenario we all hope never happens (but also kind of maybe long for a little bit?).

What the heck are you doing here?

Yeah, I used the word “heck.”

I’m going to write about coding, Wing Chun, brewing beer, and other random stuff that doesn’t fit over at eddt.ca or conservativefutures.ca.

And I need a WordPress blog for some ‘how to’ videos I’m going to start posting on eddt’s YouTube channel.

So that’s what the heck.