I have a client that requested the need to style certain blog posts uniquely based on the content of the current article. The style changes are very simple (background image or font change) so I figured adding a class to the body tag along with the post would be a good solution.
I created a new custom field and add added it to the channel to allow them to add the text of the class to the post. I then wrapped the class attribute on the body tag in a conditional statement:
{exp:weblog:entries weblog="blog" limit="1"}
<body class="archive{if body_class !=""} {body_class}{/if}">
{/exp:weblog:entries}This seems to do the trick, but I was wondering if there was a better way to handle this problem. Any suggestions anyone may have to improve on this is greatly appreciated.
Thanks!