Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

Blog Design Solutions (2006)

.pdf
Скачиваний:
28
Добавлен:
17.08.2013
Размер:
38.67 Mб
Скачать

B L O G D E S I G N S O L U T I O N S

What this chapter covers:

Introducing Textpattern (TxP)

Installing TxP

Designing a blog

Preparing images

Adding content

Creating a page template and archive section

Before we even begin with any of the technical stuff, let’s get the introductions out of the way. To its mates, of which it has many, Textpattern is known simply as TxP. For the rest of this chapter, unless I am referring specifically to the textpattern folder on the server I will call it by its more informal name: TxP.

“So what is it?” It is much more than simply a tool for creating blogs; it is a complete content management system and with a thriving community of developers and designers behind it; there isn’t much you can’t get done with a copy of TxP. For me, this is reason enough to invest a little time getting to know it. But it is also the reason why it would be too much to try and explain it all in one chapter.

Instead, I am going to concentrate on some of the key features of TxP in the hope of giving you a solid foundation from which you can move onward and upward. I will introduce you to the simple TxP tags used to build templates and how TxP itself can help you work with those tags. Along the way, we will explore the two main TxP areas, content and presentation, and we will take a quick look at the admin features relevant to your blog. With all that done, we will dive straight in to design and build a blog with TxP.

A brief history

TxP has been around in one form or another since 2001. So it’s hard to believe that it was only 2005 when the much-awaited first official stable released arrived in the form of Textpattern 4.

In the beginning, it was the creation for and of one man, Dean Allen (http:// textism.com), but has since become the passion of thousands of users like me and the more technical folk, who are responsible for the forward movement of TxP.

216

T E X T PAT T E R N

This chapter and the future of TxP

During the course of writing this chapter, TxP was updated no fewer than three times, which made the task of writing all the more challenging, to say the least. TxP does seem to be undergoing an intense period of development at the time of writing, so it has been tough choosing what to write about and what to leave out. In the end I looked at TxP’s history and what has remained consistent since the now infamous Release Candidate days, and those are the areas I have tried to stick with. In doing so, I am really touching only the tip of a very large and beautiful iceberg and I can’t emphasize enough the importance of experimenting with TxP after you are done here. On more than one occasion, TxP has surprised me with its capabilities.

Supporting the cause

TxP is free to download and use, but there are a number of ways to offer a bit of financial support if you feel so inclined. The most obvious way is to host your blog on TextDrive

servers. TextDrive is owned, in part, by TxP creator Dean Allen; if you do host with 6 TextDrive, you have the opportunity to donate some money to the TxP cause during the

registration process. At this stage, it is the easiest way to support the cause. Visit http://textdrive.com for more information.

Alternatively, there is a PayPal button on the main TxP site itself if you fancy making a oneoff donation before or after you have downloaded the software.

The creative process

My approach may seem a little chaotic and perhaps even unorganized at times. It would have been easier to put together a super slick presentation, simply to make myself look good, but a new blog is very rarely super slick and organized. Furthermore, a good blog undergoes changes constantly as new ideas are formed and as you come to grips with your content management system.

I have tried to write as I remember first approaching my own blog (joshuaink.com) in TxP. So stick with it; even if it seems to be getting a little lost, it does come to a working conclusion!

217

B L O G D E S I G N S O L U T I O N S

Installation

In the following sections, I provide an in-depth, step-by-step guide to installing TxP. If you are feeling confident about the whole process after reading Chapter 2, you can skip this bit and consult the README.txt file shipped with TxP, which provides very concise instructions on getting up and running.

Download and unzip the core files

The latest TxP release can be downloaded from www.textpattern.com/download as a GZIP or a ZIP file. If you are in any doubt about which to choose, download the ZIP file because this is the most commonly supported format on both Windows and Mac. Both versions contain the exact same software.

After the download is complete, extract the files to the root of your development server, wherever it might be. In common with other chapters, I will assume that you did not leave the root folder of the ZIP file intact, so the TxP installation starts at http://localhost/, not http://localhost/textpattern-4.x/.

The root folder contains a number of files, as shown in Figure 6-1, and some—such as history.txt and README.txt—are not necessary for running TxP, but are worth a quick readthrough before you delete them. To complete a successful setup of TxP, you should have the files folder, the images folder, the textpattern folder, the index.php file, and the .htaccess file.

Figure 6-1. Contents of the unzipped Textpattern download

218

T E X T PAT T E R N

Note that, as with other chapters, you can have TxP stay alongside your other blog software if you wish. To do so, leave the textpattern-4.x folder intact at the root of your server (though renaming it txp is more practical). This means that you will have to add the txp to all the paths mentioned in this chapter.

The .htaccess file

The .htaccess file, as shown in Figure 6-1, is probably not visible if you are using a Mac but it was placed in your root folder when you unzipped the files.

If you want to check that it is present in the folder, there are a number of ways to show

 

hidden files on a Mac (for example, using BBEdit or TextWrangler to open hidden files, as

 

described in Chapter 2). Another method is to use TinkerTool (shown in Figure 6-2). As its

 

name suggests, it lets you tinker with settings in relative safety. TinkerTool can be down-

 

loaded at www.bresink.de/osx/TinkerTool.html. After it’s installed, fire it up and find

 

the Show hidden and system files check box. Check the box, click the Relaunch Finder

 

button on the bottom right, and you should now see the .htaccess file and probably also

 

a .DS_store file (the latter has nothing to with TxP; it is a Mac system file and can be safely

6

ignored).

Figure 6-2. A shot of the TinkerTool interface

219

B L O G D E S I G N S O L U T I O N S

It is worth noting briefly that although using the .htaccess file simplifies things enormously, it is not absolutely essential for a site to run. For example, I recently found myself faced with the task of developing a commercial TxP site on a Zeus web server (www.zeus.com/) that does not use .htaccess. After the initial panic receded, I soon realized that although it required a little more thinking, the job could be done just as well without the .htaccess file. I don’t want to go in to any depth here (that would confuse the matter at hand), but it is worth remembering.

Set up a database

Of course, David has already run through setting up phpMyAdmin in some detail in Chapter 2, and we’ll follow his instructions to set up our TxP database, as shown in Figure 6-3. Fire up your browser and point it in the direction of your phpMyAdmin install: http://localhost/phpMyAdmin/. You will see on the opening page a form field with this label: Create new database. Enter your desired database name (let’s call it mytxpblog), leave the drop-down menu set to Collation, and press the Create button. Remember to make a note of the database name: you’ll need it shortly.

Figure 6-3. Creating the mytxpblog database in phpMyAdmin

You should now see a message confirming creation of the database, as shown in Figure 6-4.

Figure 6-4. Confirming the creation of the database

220

T E X T PAT T E R N

Locate the home icon just below the logo on the left side of the page, as shown in Figure 6-5, and return to the homepage.

Figure 6-5. Home icon within phpMyAdmin

From the list of options just under the Create new database form field select the Privileges link. When that page is loaded, look for the Add a new user link about halfway down the page. From here, you’ll create a user account, the details of which you will need to remember for the TxP setup.

In the User name field, enter a username such as txpusername. Set the Host drop-down menu to Local.

Ensure that the Password drop-down menu is set to Use text field, choose a password such as mytxppassword, and retype it in the Re-type form field to be sure it’s correct. The end results should look like Figure 6-6.

6

Figure 6-6. Configuring a database user

Skip straight over the Global privileges table and press Go. You should now see a new page with the heading You have added a new user. Scroll down the page to Databasespecific privileges and choose mytxpblog from the list, as shown in Figure 6-7.

Figure 6-7. Choosing the TxP database

221

B L O G D E S I G N S O L U T I O N S

The page that loads presents you with a table of Database-specific privileges, as shown in Figure 6-8. Click Check All and then deselect GRANT. This done, press Go at the bottom right of the table.

Figure 6-8. The databasespecific privileges for our example

The page then refreshes with a message at the top along the lines of this: You have updated the privileges for ‘txpusername’@‘localhost’. That’s it—job done. Time to get set up!

Running the Setup Wizard

In your browser you can now navigate to the textpattern directory, http://localhost/ textpattern/ where you will be presented with the first stage of the TxP Setup Wizard (this may be http://localhost/txp/textpattern/ or equivalent if you have installed TxP in a subfolder).

Choose your preferred language from the menu, as shown in Figure 6-9, and click Submit.

Figure 6-9. Choosing your preferred language

The next page presents you with a table for your database details and this is information you have noted while setting up the database. I’ll run through each of the sections on this page.

222

T E X T PAT T E R N

MySQL

These form fields take the information from the database you set up using phpMyAdmin and are populated as follows:

MySQL login: txpusername

MySQL server: localhost

MySQL password: mytxppassword mySQL database: mytxpblog

Unless TxP is sharing a database with something else you can safely leave the Table prefix form empty.

Site path

The Site path is the absolute path to the textpattern folder on your server. Because you

 

are testing locally, there is an easy way to check this in your browser: cut and paste the

 

contents of the site path form in to your browser and it will open up textpattern in your

6

folder, as shown in Figure 6-10.

Figure 6-10. The contents of the textpattern folder on your server

223

B L O G D E S I G N S O L U T I O N S

Site URL

TxP will probably have picked this up as http://localhost. Again, you can check by pasting the URL into your browser; you should be greeted with the message config.php is not ok or not found. If you would like to install, go to [/subdir]/textpattern/setup/. Don’t worry about this apparent error message; at this stage this is a good sign that TxP is in the right spot. If you have TxP in a subdirectory, you’ll have the corresponding subdirectory appended to the site URL.

After you fill in all the forms and checked the Site path and Site URL, your page should look very much like Figure 6-11.

Figure 6-11. Completed configuration details

Press next, and (as long as all the details you filled in are correct) TxP will connect to the database and provide further instructions, as shown in Figure 6-12. If TxP fails to connect to the database nine times out of ten, there is simply a misspelling of either the login, password, or database details. In this situation press the back button on your browser, check the details you filled in, and press next to try again. If you continue to experience problems with all information present and correct I suggest revisiting Chapter 2 and double-checking your configuration.

TxP now needs you to do a little of the leg work. A text area, as shown in Figure 6-12, contains a snippet of PHP from which we will create the config.php file.

224

T E X T PAT T E R N

Figure 6-12. TxP gives you the details for your config.php file

6

Creating the config.php file

Open up your favorite text editor, such as Dreamweaver or TextWrangler, create a new blank file, cut and paste the PHP in the text area as instructed by TxP, and save it as config.php to the textpattern directory in the root of your server, as shown in Figure 6-13.

Figure 6-13. Saving the config.php file to the textpattern folder

225