Dynamically expanding single-post sidebar

Yay, I’ve now managed to do something I always wanted for my site. It always bothered me that when I wrote a lengthy blogpost, the right side of the screen always stayed empty when you scrolled down. Unfortunately I did not want to just chuck a few random items to expand it as it would mean that even when I wrote a short post, the sidebar would draw the post down which would have the unfortunate results of making the reader scroll down too much to read the comments (as well as look ugly)

After I used the FSD Sidebar I thought to myself that I really should find a solution to my dilemma. Initially I though to use different post templates and then just select one depending on how lengthy the post came out. Unfortunately, after I created the first, I discovered that WP does not support different templates for posts but only for pages. Unfortunately I could not find a plugin to activate this functionality. This was a bit unfortunate but I didn’t give up.

I went for my second idea: To have the single-post sidebar expand downwards with more items depending on the word count of the current post. I looked around the documentation for a way to collect the word count of a post but nothing was built in WP. Fortunately a short Googling led me to the page of someone who created a plugin exactly for this reason. Perfect!

Now I only needed to figure out how to use a php statement so that the sidebar does this expansion. Unfortunately since I don’t have any php skills to speak of, I turned to the nets again and fortunately it was easy to find what I needed. Unfortunately this statement does not accept an actual sidebar item within the brackets {} but a quick look at other themes informed me to the use of <?php if() ?> and <?php endif(); ?> statement. I still don’t know exactly how to use it properly but I did manage to make it work for me so all’s well.

All in all what I did is test if the wordcount is over a specific limit and then insert the item between the if and endif. Use four of these statements for increasing wordcounts, and your sidebar will expand only when you write an appropriate number of words. Of course this doesn’t take into account pictures or videos, or even different screen resolution that might change the size , but I don’t know if there is a way to test this unless I start checking their resolution each time and changing the word count needed…hmmm…

Ack no!

FSDaily Sidebar

It was proposed to me by a member of FSDaily to add their new sidebar to my site. Apparently a few of my posts have hit their front page and that drew their attention 🙂

In case you don’t know what FSDaily is, it’s a nice digg-clone which focuses on free software issues. A good alternative since now that digg is heavily sponsored by Microsoft there are fears of conflict of interests (and also digg has become way-way to popular imho).

So I said, why the hell not and dived in. I didn’t want to put it in my horizontal sidebars above and below but thought that this might be the perfect candidate to fill up my empty sidebar on single posts. Unfortunately the way the theme is formatted, it means that when I write something long, there is nothing to see on the left other than the initial information above. I was thinking of a way to fill this and as luck would have it, I got this proposal.

I think I will create special page template that I will use for short posts and in there I will not put anything in the sidebar. However on longer posts it would be worth filling that lonely and empty part with something. Perhaps I should diversify even more and create different page templates for different content. For example, on pages where I talk about religion, I could put the atheist blogroll, and on the ones I talk about Free Software, I can have the FSD along with other related stuff.

Still, I will need to ponder on this. The best thing to do would be to widgetize my single-post sidebar and have it easily updated. I just need to figure out how to widgetize.

Oh, well. Tell me what you think 😉

PS: It is ironic that, had I left this post in the original version, you would not not able to see the sidebar on this page. This is because I’ve recently modified my theme (I’ll write about it later) to dynamically expand the sidebar items depending on the word count of the current post. Unfortunately since this was a really short post and in order to see the FSD item you need at least 400 words, it stayed invisible. My solution? Write this post script 😉 . As a matter of fact, I needed a post script with at least a 100 extra words which easily makes this the largest one I’ve ever written 😀

Comments and stuff

So I’ve put a two new tricks on my comment forms.

The first one is that you can now see a preview of what you are going to post. Just write your text and press the preview button and you should see it below. No more orthographical or html errors ;). This was done via the AJAX Comment Preview plugin. It needed me a little css tweaking in order to get it to display as I need it but fortunately I was able to find how to wrap the preview so that it fits with the normal comments.

The second one is the threaded comments option which is done through the plugin with the same name. Although at the moment you can have only one thread per comment, this might make it easier to follow the discussion in case it starts to derail (although I will admit that I don’t have so many commenters). The nifty addition to that is that the author of the comment will now receive an email notification when someone replies to his comment. The bad thing is that you can’t unsubscibe from that but given the low number of comments I get, I do not think that would be a big issue. You can still use the subscribe feature as well, but since this will inform you of every subsequent comment in the thread (even if you do not follow it anymore) most people don’t use it.

This plugin needed me even more time to get right as I needed to format the thread correctly and also test if more than one thread is viable. It is but currently the comment box is screwed on the second comment so I need to work on the css part of it. Until then I’ve enabled only a single thread replies.

One last update is that I expanded the comment field in order to give you a bigger view of what you are writing. I always found the one I had before a bit too small.

I think I’m now going to enable these on my two other blogs as well 😉

Spam-b-gone

Finally I seem to have managed to find the correct combination of WP plugins to stop spam from even logging a comment. Initially I had only Akismet, which, although good, logged the spam comments only after they were enterred and as a result my Popularity Contest plugin was affected which forced me to manually recount comments in order to fix the values. Bad Behaviour helped considerably but spam comments still kept avoiding the filter and thus bogging down my count. The latest one I tried was bcSpamBlock which appears to work admirably along with my other two spam blockers. For 2 weeks now I have not had a single successful spam comment logged in Akismet.

Finally…

Pluginess Updateness Goodness

So I’ve decided to go and update all my plugins now that WP2.3 is good enough to inform me that they have newer versions. All in all I updates Akismet, Popularity Contest, Wordbook, WordPress Database Backup, wp-cache and WPG2. Some of them didn’t make much of a difference but a few had notable improvements.

Popularity Contest actually now works with WP2.3 and it also seems to cooperate nicely with wp-cache as well, something that in the previous version required a modified version. Unfortunately for some reason my most popular posts per category still do not seem to work so I’ll need to investigate this eventually.

WPG2 seems to have achieved v3 while I was not looking and fortunately it seems to be working much better now. As part of the installation process it created a new page called WPG2 which surprised me and my old “Gallery” page stopped working. Fortunately that could easily be fixed by deleting the old one and changing the name of the new one. It still probably needs more configuration but I’ll get to that eventually.

I was thinking of upgrading to the hacked version of UTW but it seems to require double tag posting so for now I think I’ll wait a bit yet. Perhaps I could use the importing function of WP but the idea scares me a bit. If it isn’t updated soon, I may just switch to other things to see if it works. So FYI, tags are still off

Now if only I can figure out why the scrolling in the ACP site in FF in Linux is so slow…

and if it wasn’t so damn cold as well…

Broken Popularity

Hmmm, it seems that a part of the popularity contest plugin has broken too much for my limited coding capabilities to fix. I tried modifying a few entries but it did not work very well. Oh well, I’ll just wait until the newer version. Until then, just don’t expect to see the most popular posts by category 😉

I just hope that the version of the plugin I am using will be updated accordingly or at least that the original author will take this opportunity to implement the changes Richard made so that it can work with WP-Cache from now on.

Lost categories

Ok, I think I know what has happened with the upgrade to 2.3. Apparently, my wp_categories table has been renamed to wp_terms and nobody bothered to update the WP knowledge base about this little fact (at least not yesterday that I was looking for it). Good job![1]

I guess something like that must have happened since I was looking at my MySQL tables and I got a bit panicked when I noticed my wp_category and wp_post2category tables missing. I upgraded another WP installation I have for testing and noticed the change.

Now, for my problem with the “Zoulapia” error (which is part of my modified theme), I’ve managed to find the solution myself. I just needed to change the following in the function call.

("SELECT cat_ID FROM " . $wpdb->categories . " WHERE cat_name='" . $hemingwayEx_options['asides_category'] . "'")

to

("SELECT term_ID FROM " . $wpdb->terms . " WHERE name='" . $hemingwayEx_options['asides_category'] . "'")

And you can see it worked 🙂

Now I need to find out how to modify the popularity contest plugin so that it can search in the correct table when taking the popular category :-/

Oh, also the 2.3 feature that supposedly would use the previous tags you had, did not work. UTW has a (apparently) scary function to import them to [tag]Wordpress[/tag] db, but I’d rather wait a bit for that.

[1] UPADE: It seems they did mention it here

Ach scheisse!

I just updated my WP installation and things did not seem to go that well this time 🙁

You will probably be able to see that something is wrong as the new installation seems to have changed the WP categories table name and now one of my plugins that depended on that as well as a feature from my theme stopped working. Now I need to figure out in which way to fix it 🙁 Probably that will mean editing the relevant plugin and modifying the table it is looking for :-/

Oh well, at least it seems to have some shiny new features (like the notification for updates). It supposedly supports tags by itself (even using the old tags I had) so, supposedly I won’t have to use to UTW plugin anymore and this post is a relevant test to that as well. However the tag functionality does not seem as good as UTW’s (missing the list of tags etc) so it remains to be seen if it is workable.

I was initially a bit wary of the new version because of what I read it transmits to the WP servers when checking for updates, but this time I decided to leave my tinfoil hat on the side and go ahead. Seeing the results, perhaps I should have waited until the plugins were updated accordingly.

Facebook, bitches!

So here I am in Facebook now. I was never much into social sites (I pretty much loath Yourspace) and I don’t know how much this fad will last me but I’ve created a little profile and started enriching it with pics and vids and group memberships and shit.

Initially it all was so that I could help out with the Non-christian group but then I decided to start an ACP group as well and things went quickly downhill from there. Now I’m at the point where I’m spamming all my friends to join so that I can tag their faces with their name 😉

Even this post is a tribute to this monster of lost time as I’m actually trying to see if my wordbook plugin is working since it decided to make my life a bit difficult by not being configured as a good little plugin.

Anyway, y’all come and join now and then add me as a friend. I’ve got pictures with your ugly mugs around that I need to classify. If you are already there and are using nifty application, let me know of any good ones that I might like. Cheers!

Oh, I’m also posting this to the Planet LGU since we have a little group in there as well that you might want to join.