February 18th, 2008
454 CHAPTER 16 CHANGING THE LOOK OF YOUR BLOG Safer PHP Code I mentioned earlier that if a theme requires a plug-in and that plug-in is not present, you will get errors on your blog. Sometimes, depending on the place the error occurs, your blog page may not work at all. Take a look at Figure 16-18. Here, I have disabled the RSS Link List plug-in. The error on the page is at exactly the place the plug-in template function is called. No more of the template code is executed, even though the rest of the page would have displayed correctly. Imagine if you had a call to a template function at the beginning of your theme template. The resultant page might contain a cryptic error message and nothing else! Figure 16-18. Theme template code can cause errors on your blog. There is a simple solution to this problem. PHP has a special ability to test whether a function exists. This means you can test to see if the plug-in function exists before trying to call it. If it doesn t exist, you don t call it. There will be no error, and if you write your template code carefully, there won t even be a header with nothing below it. Listing 16-13 shows the new version of the code.
Check Tomcat Web Hosting services for best quality webspace to host your web application.
Posted in MySQL5 | No Comments »
February 17th, 2008
CHAPTER 16 CHANGING THE LOOK OF YOUR BLOG 453 Listing 16-12. Final Version of the Recent Comments Code in index.php
As you can see in Figure 16-17, the list is much less cluttered now. As a bonus, hovering over the link to the comment gives the comment excerpt as a tool tip. That s the title part of the code in the format parameter used in Listing 16-12. Figure 16-17. The finished recent comment list Cleaning Up the Code You have modified an existing theme, expanding it to do what you want. However, a couple areas could use some cleaning up. These involve making the PHP code safer and eliminating duplication in the CSS rules.
We would like to recommend you tested and proved virtual web hosting services, which you will surely find to be of great quality.
Posted in MySQL5 | No Comments »
February 16th, 2008
452 CHAPTER 16 CHANGING THE LOOK OF YOUR BLOG self-explanatory. For example, %comment_author% will be replaced with the comment author s name, and %comment_excerpt% will be replaced with the first few words from the comment. You could also have the plug-in output a link to the comment author s web site, if the comment writer provided one. The rest of the format parameter (taken from the plug-in author s example) puts the comment details in a list item with the link to the post on a separate line. Figure 16-16 shows the output. Figure 16-16. A different version of the recent comments list This version gives more information, but it seems rather cluttered and the most important information the name of the post and its link isn t easy to discern. So, let s make one more change to this code. You will remove the comment excerpt and just link to the comment, but with the post title. Surprisingly, although this plug-in has more than 40 replaceable tags, none of them match the desired format exactly. You could have the post title as a link to the post, or the post title as a link to the top of the comment section, but none have the post title as a link to the specific comment. However, you can create this format by using two separate replaceable tags, as shown in Listing 16-12.
Searching for affordable and reliable webhost to host and run your web applications? Go to our java web server services and you will be pleased.
Posted in MySQL5 | No Comments »
February 15th, 2008
CHAPTER 16 CHANGING THE LOOK OF YOUR BLOG 451 Figure 16-15. Recent comments listed This is a useful addition to the blog, but it could be better. It doesn t show to which story or post the comments belong. A reader might be particularly interested in what other people have to say about a story he commented on recently. A contributor might be looking for comments on her own stories. As its name implies, the Customizable Comment Listings plug-in is flexible enough to accommodate such additions. Let s replace the simple call to the plug-in function with the code shown in Listing 16-11. This is another example provided in the plug-in s documentation. Listing 16-11. New Version of the get_recent_comments Template Function in index.php
This function looks complicated, but it has only one more parameter. It uses a very powerful format template Scott has defined. Each of the terms enclosed in percent signs (%) is substituted by some data from the list of recent comments. The substitution names are fairly
We recommend you use shared web hosting services, because many users agree that it is cheap, reliable and customer-satisfying webhost.
Posted in MySQL5 | No Comments »
February 14th, 2008
450 CHAPTER 16 CHANGING THE LOOK OF YOUR BLOG Adding a Recent Comments Plug-In Now you will install another plug-in, which will list a number of the most recent comments to the blog in the sidebar. This is great mechanism to keep your readers interested. It allows them to see which topics are still being discussed, and thus is an added incentive to keep reading those topics and to continue to get involved. Real conversation about a shared interest between your readers is the lifeblood of an active online community. The plug-in is the Customizable Comment Listings plug-in by Scott Reilly. You can download this plug-in via Scott s site at http://www.coffee2code.com/archives/2005/03/30/ plugin-customizable-comment-listings/. Download, install, and activate the plug-in using the procedure covered in Chapter 15. Read through the comprehensive documentation on Scott s site. Next, add the code shown in Listing 16-9 (from one of the examples in the plug-in s documentation) to the index.php template file, just before the contribute section. The single parameter 5 tells the plug-in to list only the five most recent comments. Listing 16-9. Code to Insert into index.php Immediately Before the Contribute Links
Now add some more CSS rules to style the list of comments the same as the other lists on that page, as shown in Listing 16-10. Listing 16-10. Additional CSS Rules for the End of style.css ul.recentcomments { list-style-type: none; margin:0; padding-left: 10px; } ul.recentcomments li { margin-top: 4px; margin-left: 1em; text-indent: -1em; } Figure 16-15 shows what the default output of this plug-in looks like. Below the del.icio.us links, you have a list of the five most recent comments with the name of the comment author and the first few words of the comment. Those few words are a link to the individual comment itself. If a reader clicks the link, she will be taken to the blog post commented on with the page scrolled to the individual comment.
We highly recommend you visit web and email hosting services if you need stable and cheap web hosting platform for your web applications.
Posted in MySQL5 | No Comments »
February 14th, 2008
CHAPTER 16 CHANGING THE LOOK OF YOUR BLOG 449 The call to wp_loginout produces a link to the login page if the current visitor is not already logged in, and a logout link if the visitor is logged in. Next, add the CSS rules from Listing 16-8 to the end of the style sheet. This will ensure the display of the links matches that of the other parts of the sidebar. Listing 16-8. CSS Rules for Login and Register Links Added to style.css ul#contribute { list-style-type: none; margin:0; padding-left: 10px; } ul#contribute li { margin-top: 4px; margin-left: 1em; text-indent: -1em; } Figure 16-13 shows how your register and login links should appear, and Figure 16-14 shows the site admin and logout links. Figure 16-13. The register and login links Figure 16-14. The site admin and logout links
You want to have a cheap webhost for your apache application, then check apache web hosting services.
Posted in MySQL5 | No Comments »
February 13th, 2008
448 CHAPTER 16 CHANGING THE LOOK OF YOUR BLOG Figure 16-12. The improved list of links Adding Registration and Login Links Something missing from this template are the links to register and log in to the blog. Most WordPress blogs, being one-person blogs, don t need these links. Many themes don t even bother to include them. For a community blog, you will want to add them to your theme. To the index.php template file, add the code highlighted in bold in Listing 16-7. Listing 16-7. WordPress Template Tags for Registration and Login Links Added to index.php “show_description”=>FALSE, “num_items”=>10)); ?>
The additions in Listing 16-7 are standard WordPress template tags. The call to wp_register() produces a link to the registration page, but it does so only if registration is enabled. If you are logged in, however, it produces a link to the administration pages.
We would like to recommend you tested and proved virtual web hosting services, which you will surely find to be of great quality.