Archive for October, 2007

Email web hosting - Other page options There are some other options

Wednesday, October 24th, 2007

Other page options There are some other options you can set on this page. Although they don t play a role in our current exercise, it is worth mentioning them and what they do. Page Content Page Content allows us to add some text to the page, much as if we were writing a post. You could just type in the information you want on your page here. Page slug Ah, the Page slug. The single most useful feature on this page with the most bone-headed, unusable name. The Page slug allows you to set the URI for this page (or post, for that matter). For instance, we have entered colophon as our page slug so when we visit this page in our browser the URI will be http://localhost/colophon/. If we put nani-naniboo-boo in the Page slug field, our URI would be http://localhost/nani-nani-boo-boo/ (and that is funnier, and funnier is good). Page parent One of the smoothest features of Pages is the child/parent relationship. In WordPress you can assign a page to be the child of another page. This really becomes powerful when you have multiple pages set as children of another page. If you leave a page as the child of the main page, you will get a result similar to that shown in Figure 5-3. You see that the Pages heading on the right contains the Colophon page because the Colophon page is still the child of the main page. If you were to pick another page as a child of the Colophon page, it would be listed under the Colophon link on the right. Note that the URI of the child page is derived from the parent page s URI. For example, adding another page with a page slug of more as a child of the Colophon page would give us http://localhost/ colophon/more/. At this point you would also want to set your page order. Page Order Page order really only comes into play when you have more than one page acting as a child to a parent page. Suppose that you have a page called Gallery, and then you have three pages that are children of that page. You would use Page Order to determine the order of the children, or which page is listed as the first child, which is the second, and so on. Viewing the new Page We finished our first step. Now click Create New Page. WordPress should save the page to its database, reload the current page, and serve you with a link called Manage Pages. Click that link and you will see a list of the pages that you currently have in your database. Look for the one called Colophon, find it, and click the corresponding View link on the right side of the page. Of course, if you never created a Page in your WordPress install, it will be the only one listed here. Lucky you. WORDPRESS 197

Free web hosting with ftp - BLOG DESIGN SOLUTIONS Working with template pages Don t

Tuesday, October 23rd, 2007

BLOG DESIGN SOLUTIONS Working with template pages Don t be afraid to create new files if you need them. The ones that come with WordPress, especially archives.php and links.php, are merely examples from which you can take what you need and delete the rest. Now that we have spent some time going over the types of tags that you can access in WordPress, let s move on to creating a custom template for our site. Let s create a Colophon page, complete with a handy email me contact form. If you re not familiar with the term Colophon, you can think of it as an About Me page or a CV (curriculum vitae). First, we need to create a Page inside WordPress s admin back-end. Go to Write . Write Page (see Figure 5-3). Figure 5-3. The Write Page screen, which is where all the magic happens Title your new page Colophon, turn off comments and pings (not that it matters because we won t include the comments template in our custom Colophon template). Under Page Options, make sure that under Page Template it says Default Template.

You are currently browsing (Web design software) the

Monday, October 22nd, 2007

You are currently browsing the “> weblog archives for . If you are unable to find anything in these search results, you can try one of these links.

This last tag is a great example of using conditional tags and the exclamation mark to negate a tag. What we are saying is Return this text if this is a paged result, but only if the pages variable is not empty.

You are currently browsing the

BLOG DESIGN SOLUTIONS (Web site designers) When loaded in your browser,

Sunday, October 21st, 2007

BLOG DESIGN SOLUTIONS When loaded in your browser, the preceding will be executed and displayed as follows: background: url(”http://www.bobssite.com/wp-content/themes /default/images/kubrickheader.jpg”) no-repeat bottom center; Simple enough. If you know the path your images will take, you can move this block to the style.css file, removing it from header.php, which helps clean it up a little. That s it for the header; now let s open sidebar.php and see how Kubrick uses the conditional tags we spoke about earlier. Around line 15 you will start to see where the conditionals come into play. The first conditional we call is (is_404()). This tag handles situations when the user requests a page that doesn t exist, so you would place whatever text you want to show the user after the closing tag (?>) but before the next opening PHP tag ( Now when users look for something that is not on our site or has been removed, they will be shown that friendly bit of text and be called hoss. Next is the conditional tag (is_category()), which checks to see whether the user is browsing a category; if so, it displays the following message:

You are currently browsing the archives for the category.

And next are (is_day()), (is_month()), and (is_year()) which return the appropriate text if the user is browsing a day (mysite.com/2005/05/21/), month (mysite.com/2005/05/), or year (mysite.com/2005/) archive.

You are currently browsing the “> weblog archives for .

search.php To make it easier to provide hints

Sunday, October 21st, 2007

search.php To make it easier to provide hints for searches, they are provided with their own template. 404.php When WordPress can t find the data you re looking for, it will present you with this file. By default, there s nothing on the page other than a short remark, telling the user the obvious (Error 404 - Not Found). Michael has added a range of tools for the user on his site, making it easier to go from there to something that might be of some use (you can see it by going here: http://binarybonsai.com/gimme404). archives.php The Pages functionality in WordPress allows you to select a template for each page you create, and archives.php is one such template. It allows you to create a quick archives page that can act as a base for further exploration into the archives of your blog. links.php As with archives.php, links.php is a Page template, meant to make it easy for you to create a Page to display your links. It includes the necessary code for fetching your links from WordPress s Link Manager. Taking a closer look at the code If you open up index.php in your favorite text editor, you see a very large amount of code, which can be hard to decipher. So let s take a stab at demystifying it a bit. The Kubrick main template is comprised of header.php, footer.php, sidebar.php, and searchform.php. If you now open header.php, you can see where the complexities begin. Just after the pingback code, there is a block of inline CSS. This CSS is there to help the average Kubrick user with adding a custom image to the header. From the Kubrick header.php file: To accommodate differing install paths of WordPress, images are referred only here, and not in the wp-layout.css file. If you prefer to use only CSS for colors and what not, then go right ahead and delete the following lines, and the image files. What this means in English is that because not everyone uses the same server, WordPress and thus your theme will be located in different places. On one machine it might be at /www/home/bob/wordpress/, whereas on another machine it might be at /vhosts/ bobssite.com/wordpress/ you just never can tell. To help with that problem, this block of CSS lets you explicitly set the path to an image by calling one of the theme-specific template tags: background: url(” /images/kubrickheader.jpg”) no-repeat bottom center; WORDPRESS 193

Web host 4 life - BLOG DESIGN SOLUTIONS header.php This file is inserted

Saturday, October 20th, 2007

BLOG DESIGN SOLUTIONS header.php This file is inserted at the very beginning of every page. footer.php Similarly, this file is inserted at the very end of every page. sidebar.php The sidebar.php file contains all the things that belong on the sidebar. Who would ve guessed, eh? Having it in a separate file allows us to make changes once and then register everywhere we include the file. single.php When calling up a specific entry, this is the file used. page.php WordPress comes with a functionality that will allow you to create Pages that behave in many ways like a static HTML page would. Say you wanted an About page for your blog: you could create it from within WordPress s administration back-end without ever having to toy with separate .html or .php pages. This can save you quite a lot of trouble in terms of aligning your design and layout across the entire site. Be aware, however, that you can t use PHP within a page s content (at least not without a third-party plug-in). comments.php This file is called from single.php, showing the comments, pingbacks, and trackbacks of the entry being called. Essentially it is also possible to use comments with the Pages function of WordPress (which makes it possible to create, for instance, a static About page for your blog), should the need arise. comments-popup.php Essentially performs the same function as comments.php, except it was created to work in a pop-up window instead of inline with the entry. We consider this template a leftover from bygone days and can t remember the last time we saw a WordPress-powered blog using it. searchform.php To make it faster and easier to make changes across the entire blog, the search form resides in its own file. archive.php When going back into the archives, such as when you re viewing a specific month, this is the template used. By default it calls the entries using the_excerpt instead of the_content, which makes for faster skimming through larger quantities of entries.

WORDPRESS Kubrick Kubrick (Free web servers) is the code name for

Friday, October 19th, 2007

WORDPRESS Kubrick Kubrick is the code name for the template that comes with WordPress 1.5, nicknamed after the late director Stanley Kubrick. Michael designed the first version of Kubrick in July 2004, and it was officially adopted into WordPress with the 1.5 release in February 2005 (adopted so very proficiently into the new template system by Ryan Boren). We ll spend a little time taking Kubrick apart so you can see how all that we have talked about applies to an actual theme. Using Kubrick as a base for your own template is a good idea because it is likely to save you a lot of headaches and oversights, but there is no replacement for creating your own work of art from scratch. Take a look at Kubrick and learn the ropes; then try your hand at creating something from scratch. The files Kubrick comes bundled as 14 template files and a directory for images. Each file performs a specific task, and working together they grab, format, and display your blog content for all the world to see. Let s have a look at each of the files and what job it performs. style.css This is the only file that you absolutely have to have for your theme to really be called a theme. The rest of the functionality needed for WordPress to function is already present. Because this is the only file needed, it is also where the metadata about the theme goes. If you open the Kubrick style.css, you ll find the following lines at the top of the file, pre ceding the actual CSS information: Theme Name: WordPress Default Theme URI: http://wordpress.org/ Description: The default WordPress theme based on the famous Kubrick. Version: 1.5 Author: Michael Heilemann Author URI: http://binarybonsai.com/ This code is mostly self-explanatory, and when it comes time for you to create your own theme, you simply make a copy of the Kubrick directory, change this information, and voila you re in business. index.php This is the file the user is presented with when viewing the frontpage of your site. By default, it shows a header, two columns, and a footer with the main column containing a loop for displaying blog entries. 191

Ipower web hosting - BLOG DESIGN SOLUTIONS Pages WordPress was initially geared

Thursday, October 18th, 2007

BLOG DESIGN SOLUTIONS Pages WordPress was initially geared toward the chronological publication of journal-like entries (what have become known as blogs). Increasingly, the support forums were filled with people trying to manage and power their entire site with WordPress. What people were screaming for was more of a CMS than a blogging platform. After some debate, it was decided that there would be real benefit in folding this kind of functionality into WordPress, and since version 1.5 these CMS-like features have been available from within the WordPress admin interface (to create a Page, go into the administration back-end of your blog, select Write and then Write Page). These static posts are simply referred to as Pages (notice the capital P) and they are, in essence, the same as a post. Pages are stored in the database in the exact same way as posts and can have comments, and register pingbacks and trackbacks just like normal posts. However, Pages differ from posts because they don t use the category system and they fall outside of the normal blog chronology. You also have the option of organizing Pages in a tree-like hierarchy and choosing a custom template on a per-Page basis. We will talk more about applying custom templates to Pages later in this chapter. Although you can manually create links to your Pages, an easier way of going about this is to use wp_list_pages. This template tag outputs a linked, nested list of the Pages currently available on your site. You can read more about wp_list_pages here: http://codex. wordpress.org/Template_Tags/wp_list_pages. (You also can read more about the Page s functionality in the WordPress Codex at http://codex.wordpress.org/pages.) Comments Comments are one of the most exciting and community building aspects of blogging. Enabling commenting on your blog promotes conversation and exploration. Some of the most meaningful content on weblogs is in the comments, not necessarily in the posts themselves. WordPress has a robust commenting system, incorporating trackback, ping- back, and per-post commenting. Themes in WordPress 1.5 As of WordPress 1.5, all themes and plug-ins are stored in /wp-content/themes/ and wp-content/plugins/, respectively. This is important to note, since it is a life saver when you are trying to troubleshoot a broken theme or plug-in. Both themes and plug-ins are activated through an admin interface located at wp-admin/themes.php and wp-admin/plugins.php. In these pages, you can see which plug- ins or themes are currently active and you can activate or deactivate plug-ins and themes. WordPress ships with two themes installed: the original theme (pre WordPress 1.5) by Dave Shea is labeled Classic, and Kubrick is labeled Default.

You make (Mac os x web server) use of include tags to construct

Thursday, October 18th, 2007

You make use of include tags to construct your site from the modular pieces. Using this method you can create a single header, footer, and sidebar that can be included in any page you create for your WordPress-powered site. The default include tags and the theme template files they look for include get_header (header.php, wp-header.php), get_footer (footer.php, wp-footer.php), get_sidebar (sidebar.php, wp-sidebar.php), and the odd one out, comments_template (comments.php or comments-popup.php, wp-comments.php or wp-popupcomments.php). Conventional wisdom is to name your theme template files without the preceding wp-, but if you name them wp-something_or_other.php, they will still work. At the most basic level, you could create a theme template which looked like this, and it would work as you would expect it to: Content goes here Theme templating doesn t stop here, though. Let s say that you want to expand your template to have a third column with the new sidebar being a theme template file called sidebar2.php. You would simply place: In your master theme page, this has the same effect as the default include tags. When viewed in a browser, sidebar2.php will be included in your page. Content types in WordPress By default, there are three types of content in WordPress: posts, pages, and comments. Each content type has its own unique features. Leveraging all three will give you the most robust and feature-full blogging experience. There are other content types that can be added to WordPress via plug-ins, such as Chris s CJD Notepad plug-in (www.chrisjdavis.org/cjd-notepad/), which allows you to create notes via the WordPress admin interface. This can be helpful when researching topics to blog about. Enough with the shameless promotion. Back to the action: Let s talk about posts. Posts The bread and butter of any blog is the post content. A post is a single entry on your blog, tied to a category and a date. You could have three posts for one day on your blog, all in different categories, or just one post in one category. Posts live within your blog chronology, meaning they show up on your index.php page and are navigable by month, year, and day as well as category. It is your posts that will drive the content and direction of your blog, as well as generate wider conversation through commenting if you choose to enable it. WORDPRESS 189

BLOG DESIGN SOLUTIONS This is not the frontpage (Web page design)

Wednesday, October 17th, 2007

BLOG DESIGN SOLUTIONS This is not the frontpage or a permalink page. When the page is being served to the user, WordPress first checks to see whether this is the frontpage. That is, whether it is being loaded without any parameters (as discussed in the Displaying your blog posts section). If that is the case, WordPress stops there, and This is the frontpage will appear in the browser. If that isn t the case, it will move on to check whether the current page is a single page or if we are viewing a single article/post. If that s the case, This is a permalink page will be printed. And finally, if neither is the case, This is not the frontpage or a permalink page will be presented to the end user. If-else, conditional PHP statements are fairly straightforward, but it is always a good idea to get better acquainted with your tools, so I recommend skimming over the documentation for if, else, and elseif at the PHP manual site (http://php.net/if). The versatility of the if-else conditional statements will get you a very long way. Another very gnarly use of if-else conditional statements is combining them, like so: This is either the frontpage or a permalink This is great for saving some space and can alternatively be combined with something like this: This is not home Whenever you place an exclamation point in front of a variable, it negates the variable. So in the preceding code, we are really saying that if this is not home, display the text This is not home, whereas if we are on the frontpage, it will not be shown. Crafty use of these techniques can help keep the number of individual template files you will use to a minimum, but dramatically increases the complexity of each template file. There are trade-offs in everything, after all. Include tags A third type of template tag available in WordPress is the so-called include tag. WordPress themes are modular in design, having any number of theme template files. This modular design allows for some pretty exciting possibilities. At a minimum, a WordPress theme has to have a stylesheet, header, footer, sidebar, and index theme template.