3 Aug
Recently at work we looked at some JavaScript apps that create nice-looking pop-up windows, which replace the boring old pop-ups that you see all over the Net. In particular, we looked at Greybox and Thickbox, both based on Lightbox. Whenever I see something neat like this in one of our team meetings, I look for a way to add it to my own bag of tricks. This is one one instance (of many) where I failed miserably.
I looked at two Wordpress plugins that would facilitate the use of the ‘boxes. Both written by the same developer, the Greybox WP plugin and the Thickbox WP plugin looked like an extremely simple way to add a little bit of flair to this site. I was wrong.
At first, Thickbox worked okay on anything that wasn’t a PHP file, which made it largely worthless to me as I wanted to display images from the gallery in a pop-up (you may notice that they all end in the PHP extension, not in JPGs as one would expect). I made my own edits, then some based on the work done by posters on the Thickbox developer’s site. At some point, I broke the plugin beyond repair, and nothing would appear anymore.
I moved on to Greybox. The developer demonstrates on his site how practically any file can be opened, so I would have no issues based on the extension of the file. Assuming it would meet my needs nicely, I went ahead with it. With this ‘box, I never got the anything to appear in the pop-up. I saw a flash of the Greybox, but then the page loaded in the browser without opening the pop-up.
I think I wasted enough time on these ‘boxes. Feel free to head over to one of the links above and see how they look when they work correctly.
Edit: Corrected spelling mistake. Also, I just wanted to say that I was not trying to say anything negative about any of the code that I linked to. The issue is solely on my part; I screwed something up.
2 Aug
Are you tired of typing this kind of if statement?
$a = 10;
if ($a > 10)
{
$message = “variable ‘a’ is greater than 10″;
}
else
{
$message = “variable ‘a’ is not greater than 10″;
}
echo $message;
Try this kind instead:
$a = 10;
$message = ($a > 10) ? “variable ‘a’ is greater than 10″ : “variable ‘a’ is not greater than 10″;
echo $message;
The syntax is variable name = condition ? value if true : value if false; I tried to throw some echo statments in place of the values, but PHP doesn’t like that at all. Typing your if statements in this manner could save you a few lines in your code and help to make it easier to read.
I’m sure experienced PHP developers would scoff at this tip, saying “this is so 2001; where have you been?” I still consider myself a rookie at this, so I’d like to help other rookies. Besides, php.net doesn’t explicitly document this syntax (I had to look through the comments to find this).
Edit: On further investigation, I found that I can shorten that even further:
$a = 10;
echo ($a > 10) ? “variable ‘a’ is greater than 10″ : “variable ‘a’ is not greater than 10″;
18 Jul
Now that blogs have become very popular, the concept of a guestbook has become antiquated. Why have a single page for comments when your visitors can comment on every single post you make?
Guestbooks still have a place on the web, even if their use is decreasing. This blog still uses a guestbook. I have long since scrapped my poorly-written script that older versions of this site used, mainly because it was susceptible to spam. I replaced it with a simple yet little-used WordPress trick: create an empty page with comments enabled. That’s it. Performing that one step effectively creates a guestbook.
There is only one issue with it: the comments are listed in the order they were originally posted, forcing users to scroll to the bottom of the list to view the latest entry. WordPress does not have a built-in way to reverse the comment order, which makes sense. It is common practice in blogs to list comments in the order they were posted, whereas guestbooks are listed in reverse order. Since WordPress is a blog platform, I can’t fault them for that.
That is where the wp-zy-roc plugin comes in. Put simply, you change a single line in that empty page I mentioned earlier (after installing and activating the reverse order plugin). Once that is done, your comments are now in reverse order. I applied the plugin to this site in less than five minutes; see them in action in the guestbook and on the You Make Kitty Scared page.
Edit: Another great plugin is the category tagging one, which creates a tag cloud. After seeing Joe’s setup for his del.icio.us links, I thought it would be a nice change from the boring old unordered list of categories that we currently use. Take a look in the sidebar and let me know what you think.