Styling Chyrp Posts By Aggregate
So you’re balling the Aggregator module but then you realize that even though you have three different types of aggregates which output Link feathers, they all come out looking exactly alike.
The obvious solution is to give each post’s containing div a class with the name of the aggregate that produced it. So that’s what we’ll do.
Open up content/post.twig from inside your theme’s folder, and look for the line that starts with:
<div class="post $post.feather ........... "
That’s where we add our class by putting the following inside the class=”” property:
{%if post.aggregate %} ${ post.aggregate | lower }{% endif %}
That leaves that line looking like:
As you can see, it just transform’s the aggregate’s name into lowercase and outputs it as a class.
The only gotcha here is that it doesn’t do any cleaning, so if your aggregate’s name has anything besides letters and numbers, your code won’t validate.
BONUS TIP: If your aggregate’s name is more than one word, it outputs each word individually as its own class. So if you have a “Delicious Bookmarks” aggregate and a “Blahblah Bookmarks” aggregate, both post types will get “bookmarks” as a class, along with getting “delicious” and “blahblah” respectively. That way, you can have them share CSS styles by targeting that bookmarks selector.
Make sense? No? Oh, sorry.