Hiding Categories from the Jekyll Paginator, Unless, and Insert statements

March 3, 2016
Category: TIL
Tags: Jekyll, Liquid, SQL, and PHP

Today I learned:

Hiding Categories from Paginator

According to the Jekyll docs, the jekyll-paginator plugin does not support categories or tags. That means there is no way to exclude a category as a whole. You can only exclude posts individually by including hidden: true in each post’s YAML front-matter.

I’m hiding all of my TIL posts from the front page of my site, so I did a global find and replace to accomplish it.

Mirror of If statement in Liquid

Liquid has a neat concept that is the inverse of an If statement. It executes if a condition is not met.

{% unless post.categories contains 'TIL' %}
	Code here to display all the things!
{% endunless %}

Inserting via mysqli()

Using the mysqli() function I wrote about yesterday, here is how to insert something into a table:

$connect = new mysqli($server, $db_username, $password, $db);
$connect->query("INSERT INTO `table_name` (username) VALUES ('$user');");

Make sure your variables are sanitized first! You don’t want someone doing a SQL injection.

Eric Davis told me that mysqli() is the old way of doing things and I should check out PDO instead.

Find this post useful?

Buy me a coffeeBuy me a coffee