What if I want a different title colour for some articles?

Since some articles on this page are in Dutch and some in English, I thought it would be a nice idea to give the titles different colors... That turned out to be quite a challenge, because in Joomla you cannot add a CSS class to an article.

I asked about it in the forum, and user Mr. Wimpy took the trouble to figure out an override that would do the trick! Very clever!

It works very nicely!

Since it's an override to the file blog-item.php it does work on all articles in blog view on this site - that's most of the articles... So to avoid error messages in the page HTML, the Field needs to be "available" for all categories. Initially I had it set to just the category of these articles, and that triggered the error message on all the other "category blog" pages.

It works as follows:

First, add a field to the article, where you can select the CSS class for the color you want.

Then make an override to blog-item.php:

// Get fieldname
$myfield = $this->item->jcfields;
foreach($myfield as $field) {
    $myfield[$field->name] = $field;

And then add a PHP statement to the class "item-content" (line 42 or thereabouts):

<div class="item-content <?php echo $myfield['article-sfx']->value; ?>">

where "article-sfx" is the name of the field.