Skip to main content

Using tt_address

Why bother with tt_address?

tt_address is a plugin to handle people and their addresses. Installing the plugin creates a database table (named tt_address), and a plugin to view addresses as list or in single mode. It is always good to structure your data, so you really should use this plugin. But there is more: tt_address utilizes mapping, where appropriate, so names and phone numbers get proper markup.

Importing addresses

When you already got lots of addresses somewhere, it is no fun retyping them. Addresses get stored in the table tt_address. There is no official importing interface, but you don't need any. I proceeded the following way: I created two addresses and exported the table to csv (use phpmyadmin or your favorite database tool for this purpose). I exported my address list to csv, too. The next step was to reorder columns and to add columns to my addresses until the format matched that of the table exported from Typo3. Inspecting the two exporterd addresses, I came to the following conclusions:

  • uid is the primary key, so it should be different for all lines in your file. Inspecting the database structure shows that it has an autoincrement, so you could rely on mysql increasing it on its own when you always supply zeroes.
  • pid is the number of your folder holding the addresses.
  • sorting holds spaced out numbers to create a sorting order.
  • slug is the terminal part of a speaking url. It consists of firstname-lastname. Important: Use only lower case, asciify umlauts and accented letters. Slugs will be rewritten whenever you edit and save a person's record.

Most of the other columns are self-explanatory. When you build your csv file with spreadsheet software, you have to take special care about the last column (t3ver_label in this case) – if it is empty. Otherwise you will get complaints about missing data. I prefer to fill the last column with a marking text, save the csv file, replace that marking text with the help of a text editor by an empty string, and save again.

I did the import with phpMyAdmin. phpMyAdmin did not add the date to tt_address, instead it created a table called 'TABLE 88' and put the data there. So I issued

INSERT INTO tt_address SELECT * from "TABLE 88";

and was done.

The next task was to tag addresses with categories. It works apparently like this: In table tt_address, there is a column categories. As categories are a multi-valued attribute, they are not stored there. You put a 1 into this column if an address has a category. Then you have to add a record to the table sys_category_record_mm. This table provides the m:n relation between categories and addresses. Here is the content of the columns:

uid_localKey of category.
uid_foreignKey of address.

Inserting records with SQL is straight forward and probably faster than editing each address in the Typo3 backend. For getting it right, you will probably edit one record by hand and then check the tables before doing SQL.

Getting speaking urls for persons

With a routing enhancer, you can get Typo3 to accept urls in the form of when you have a person called Donald Knuth in your tt_adrress data. These are the prerequistes:

  • You need to have an address list on some page.
  • You need to have a page for displaying a single address. I named this page Person and put it into a folder with pages that get not included into menus.
  • You need to setup your list so that clicking on 'Details' for a person leads to the single address page.

Now you need to edit the file config.yaml. It lies within [www-root]/typo3conf/sites/[yoursitename]. With a shared webhosting service, you have to fetch the file by ftp, edit it on your local machine and put it back by ftp – as you probably know. Keep a backup of your original file, just in case anything goes wrong. 

To me, it worked by copying the settings documented in Routing in 9 example by Georg Ringer. Above his code, I added 

# Adressen automatisch Seiten zuweisen.

Yaml is visually formatted, so you have to take care of indetation. the first line starts at the first column, the line starting with TtAddress: (already copied from the source mentioned above) has two spaces to the left, and so on. When you're done, don't forget to flush all the caches.