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>
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.




Bull3t's Blog is a next generation web log written by me, Philip Hughes (also known as Bull3t), a first-year college student living in England, aged 17. I write this blog for the sake of doing so, posting about anything I see fit. 

So what now?
You've reached the end of this post. Seeing as you made it this far means you might be interested in the following related articles and resources.10 Comments
May 5th, 2007
#1
Should work on Unwakeable too. I'm actually building in those sorts of icons into Unwakeable 2.0, which I hope to release by the end of May, but who knows. :)
I like the category cloud a lot compared with a straight list of categories. Might be something I could add an option for in Unwakeable 2.0.
Looks good Bull3t.
May 5th, 2007
#2
Yep, that would look nice, feel free to steal the tweaks that I made on K2 and implement them into Unwakeable, the category cloud is actually a plugin called Category Tagging, which makes a sexy cloud.
May 5th, 2007
#3
One thing I've done in Unwakeable 2.0 that I notice you've done here is move the ratings and post views up to right under the post title when viewing a single post or page.
I'd like to come up with a clean mimimalistic style for displaying that data but am having trouble. I think I like it how you have it, simple on the white background. Maybe I don't even need to worry about styling it now that I see it would look good simply white.
Are you using sidebar modules from K2 or the WordPress Widgets? Or are you using a static sidebar.php file?
May 6th, 2007
#4
To get the ratings/views to show as if they are part of the theme I just simply copied the following code from theloop.php:
<?php /* Tags */ if (is_single() and function_exists('UTW_ShowTagsForCurrentPost')) { ?><span class="entry-tags"><?php _e('Tags:','k2_domain'); ?> <?php UTW_ShowTagsForCurrentPost("commalist") ?>.</span>
<?php } ?>
Pasted it underneath itself and then changed it to do the following:
<?php /* Ratings */ if(function_exists('the_ratings')) { ?><span class="entry-rate">Rating: <?php
ob_start();
the_ratings();
$remove_divs = ob_get_contents();
ob_end_clean();
echo str_replace('div', 'span', $remove_divs); ?> </span> <?php } ?>
Copied/pasted it again and changed it for the views:
<?php /* Views */ if(function_exists('the_views')) { ?>
<span class="entry-views"><?php the_views(); ?> </span> <?php } ?>
Basically, where you can see that it says class="entry-rate" and class="entry-views" I simply opened up the K2 style.css file and copied the entry-tags style, changed it to suit the new images and location. Works a treat.
If you would like me to email you the two files (theloop.php and style.css) I would be more than happy to do so.
I use the K2 Sidebar Modules for my sidebar as it seems to be a hell of a lot easier and nicer looking.
May 26th, 2008
#5
what's up…i NEED someone to help me edit my K2 theme!!! i need to change a bunch of things. like one, under my header, you can't see the tabs because they're white and so is the text. i need to change that! also, i want to change the color of the links to match the DC to BC logo / colors better. any ideas!? please email me… modi10 at gmail dot com. thanks a LOT.
October 6th, 2008
#6
wow these tweaks are very useful for me and these really helps me to learn something new from here.
Thanks for sharing this buddy.
October 31st, 2008
#7
Hi thank you. I am still learning with Wordpress and this is very helpful. Thanks!
January 6th, 2009
#8
hey great tutorial.
will modify my wp asap.
thanks
June 19th, 2009
#9
If the K2 theme is still what you're using here, it does indeed look quite a bit different from the vanilla version. I'd guess you've changed themes though since this is such an old post… but there's no indicator in your footer as to which theme you're using now. Is it still a K2 mod, or something different?
June 25th, 2009
#10
@jayboy75… I was wondering the same thing, is this site using the K2 theme with all the mods added.
If it is, I would certainly try out the theme and try to add the mods.
Leave a reply