Please note that you may have been redirected (you might like to make a note of the URL in the address bar of your browser and update accordingly) This is a permanent archvie but is no longer actively maintained. Please visit http://joshuaink.com for the latest updates.

Rebuild Day 3

Monday October 25, 2004

I have decided to document my rebuild quite thoroughly, two reasons:

  1. It may be useful for an absolute beginner sometime.
  2. If I do something stupid, I am sure some passing guru will let me know.

This session will cover setting up image uploads and clean URL's.

Images

I am going to want to do some screen shots to help me explain things, so first stop in the textpattern admin is Content > Images and here we find a warning to the effect "Please change file permissions to 777". I use WST_FTP Pro for all my FTP needs, so that's what the screenshots below show.

Select, create or upload the folder "images" on to the root of your server, right clicking this will produce a menu as as shown below. Scroll down to Operations > FTP Commands > CHMOD (unix).

Note: when I say "server root" I mean the public folder, the same place as your textpattern folder resides, this may be something like www_root or htdocs.

Screenshot of FTP menu

This will bring up the permissions window and all we need to do is change the permissions to 777, job done.

Screenshot of permissions options

It is worth noting that texpattern will rename your images when it uploads them so you need to make a choice as to whether you do want to let the software organize your image folder; first time round I used FTP but I am going to give it a whirl as it looks pretty good. From here on in it's pretty self explanatory but I note that when you click on the XHTML link associated with an image (and handy way to find out the path to the renamed image) it produces a tag containing inline styles, I won't be using these and I won't be hardwiring their width and heights either, you can view the source of this page to see the XHTML I have used for images.

Clean URL's

Are they really necessary, clean URL's? Who knows but they seem like a bit of a right of passage in the blogging world so we better set them up.

Before we do anything, open up your FTP client and see if you have an existing .htaccess file on your server, it may be hidden, in WS_FTP there is a small text input area and typing the letters: -al will show all files on the sever. If there is a .htaccess file in there download it and keep it somewhere safe as a backup. If you are not confident about .htaccess, it might be worth checking with your hosting provider what purpose it plays on your sever before you go messing with it.

Screenshot of command for hidden files

In the textpattern admin go to Presentation > Sections and you will see that there are already two sections in place, articles and about. In the textpattern download there are two files called articles and about, bingo! Upload these two files to the root of your server. Textpattern also comes with a .htaccess file and as it suggests there are several ways to create clean URL's. I went for the FilesMatch method and within the provided .htaccess you will find the following:

  1. #<FilesMatch "^([^\.]+)$">
  2. #ForceType application/x-httpd-php
  3. #</FilesMatch>

Simply remove the hashes from the beginning of lines 1,2 and 3 and upload the file to your server, or if you need to keep your existing .htaccess file in tact, add this code to the bottom. In the textpattern admin go to Admin > Preferences and look for the URL mode, this is probably already set to "/" but if it is set to messy, change it to "/clean/" and you are done.

For every textpattern section you create you need a corresponding file on the sever, easiest way to do this is to open up the "articles" file, modify it and save a copy with the exact name of the section. For example to create an ARCHIVES section I would open up "articles", save it as "archives" then modify the code thus:

  1. <?php
  2. include "./*******/****.php";
  3. $s = "archives";
  4. include $txpcfg['txpath']."/*****.php";
  5. textpattern();
  6. ?>

Note: I have removed the paths to specific files and replaced them with xxxxx, obviously you don't need to do this!

With this done pop back to textpattern Presentation > Sections and create a new section called archives, job done and I have done it here, if you go to /archives you will find a spot ready for all the riveting content to come.

Screenshot of Section

That's it for now, time for a nice cup of tea!

  1. Ray

    1964 days ago

    I’m curious: why not hardwire the width and height into the images? Call me old-school, but isn’t that making the browser work a wee bit harder than it has to?

    Also—another example of root folders would be the public_html folder, and if you would like to further round this tutorial, for .htaccess newbies such as I, explaining what a hash mark is would be sweet.

    Example:

    # that little guy to the left is a “hash” mark. It is useful for “commenting out”, or “escaping” any line of code in a .htacess file you wish to disable.

    Good thing I know that, huh?
  2. John Oxton

    1964 days ago

    And a useful addition to the tutorial too! :) That’s what the comments are for folks… I am open to ALL suggestions !
  3. Ray

    1964 days ago

    God, man. Aren’t you in the UK? In the colonies (Canader) it’s 10:12 AM.

    What time is it there, 6:12 PM?

    I love the web.
  4. John Oxton

    1964 days ago

    That’s a good point it’s 5.15 on a Sunday evening here… what am I doing messing around with my site! ;)
  5. Daniel

    1953 days ago

    Sorry I still try getting textpattern do what I want to do…

    If I do as you wrote above, and I create a new section called xyz I still miss is on my server there is no http://blabla.com/XYZ it is just empty, is there something i did miss?
  6. John Oxton

    1953 days ago

    Daniel

    Can you email me a link and show me the file you uploaded to the server?