You may or may not have noticed that I have been making some small tweaks to my blog to make it look that little bit more unique. I have been doing a lot of editing in the K2 theme department and nearly every plugin I have for this blog has been tweaked to be a little better. Hardly anything is the same as it was out-of-the-box. I do this simply to make it more user-friendly, readable, displayable and mostly to make it look the part.

Some of these edits only change parts of the coding to make it quicker to load, thus making it less time-consuming for you, as a reader, to browse through my blog. Others are simply to change the output such as cases, to add punctuation and so on, basically anything that I think should be there that isn't. I have made a few edits to theloop.php file within the K2 theme directory so that I can add the post ratings, views and some other small features.

Currently the biggest tweak I have had to make would be to add those little icons you can see on the right hand side of the sidebar headers (at the time of posting), I added this feature today. To do this I had to edit 2 files in my K2 theme directory, the first was the k2/app/display/sbm-ajax/edit-module-form.php file, this is what shows the sidebar modules' options on the administration panel of the K2 Sidebar. In here I had to add the following:

<p>
<label for="output-prefix-image"><?php _e('Prefix Image', 'k2_domain'); ?>:</label><br />
<input id="output-prefix-image" name="output[prefix_image]" type="text" value="<?php echo($module->output['prefix_image']); ?>" />
</p>

After this, on line 25:

<p>
<label for="output-css-file"><?php _e('Related CSS file', 'k2_domain'); ?>:</label><br />
<input id="output-css-file" name="output[css_file]" type="text" value="<?php echo($module->output['css_file']); ?>" />
</p>

Showing the tweak made to modules page.Producing what you can see on the right. After I had added that and managed to get it to work I then had to open k2/app/classes/sbm.php which is what is used to draw the sidebar when the page loads for the user. In this file I had to change:

$params[0]['after_title'] = $sidebar->after_title;
On line 766, to this:
if($this->output['prefix_image']) {
$params[0]['after_title'] = "<span class='metalink'><img class='feedlink' src='" . $this->output['prefix_image'] . "' /></span>" . $sidebar->after_title;
} else {
$params[0]['after_title'] = $sidebar->after_title;
}

Which I admit, proved a little difficult to get working at first, trial and error works just fine though. Basically, what that last bit does is add an image which is aligned to the right on the same line as the title of the sidebar module currently being processed. When I say processed, I mean when WordPress goes through every module that you have added to the "Sidebar 1" list in the K2 Sidebar Modules admin page, adding them to the current page's sidebar, one after the other. It reads the image location from the textbox, highlighted in the screenshot above, with this line of code: $this->output['prefix_image'] which reads whatever was last saved to the database under the module's ($this) settings.

If you are still unsure of what I am talking about then don't worry, all that you really need to know is that it wasn't easy to do originally and took me a good few hours. All you need to do is follow the steps to do it for your own K2 blog. This may also work with the Unwakeable theme by Tyler Longren.