Login / Status
developer.Resource
Home . Documentation . Document Library . Extension Manuals
Sponsors
hosted by punkt.deTYPO3 and Open Source Magazine

1.4. Tutorial

How to set up the extension

Please read the section "How to set up the extension" in the chapter "Debug" on page 8.

tt_news

Illustration 8: The result

The result on the page with the single view of a news should be:

  1. The browser title is composed of the title (1) and the subtitle (2) of the news.

  1. That the <meta>-tag description (3) is the value of the short (3) field.

  2. That the <meta>-tag keyword (4) is the value of the title (1) and the subtitle (2) of the news.

We need the following typoscript setup

temp.seo = COA

temp.seo {

  10 < plugin.tx_seodynamictag_pi1

  10 {

    # Example for the page title

    special = title

    query {

      select = CONCAT(`title`, ': ', `short`)

      from  = `tt_news`

      where  = `uid` = $1 && `deleted` = 0 && `hidden` = 0

      var.1 = tx_ttnews[tt_news]

   }

  }

  20 < plugin.tx_seodynamictag_pi1

  20 {

    # Example for a meta tag

    special = register

    register = description

    query {

      select = `bodytext`

      from  = `tt_news`

      where  = `uid` = $1 && `deleted` = 0 && `hidden` = 0

      var.1 = tx_ttnews[tt_news]

      maxLength = 200

    }

  }

  30 < plugin.tx_seodynamictag_pi1

  30 {

    # Example for a meta tag

    special = register

    register = keywords

    query {

      select = CONCAT(`title`, ' ', `short`)

      from  = `tt_news`

      where  = `uid` = $1 && `deleted` = 0 && `hidden` = 0

      var.1 = tx_ttnews[tt_news]

    }

    keywords = 1

    keywords {

      amount        = 10

      minLength     = 8

      positiveList  = CMC, Nokia

    }

  }

The temp.seo object ist the last content element of our page.

It has to be the last element, because we have to avoid, that other content elements override our browser page title or our <meta>-tags.

page {

  ...

  10 {

    subparts {

      content = COA

      # The single view of tt_news

      content.20 < temp.single

      # If the seo-plugin should overwrite values like the page title,

      # the plugin have to be the last content element

      content.1000 < temp.seo

  ...

General Explanation

We choose a Content Object Array (COA), because we want more than one thing.

temp.seo = COA

temp.seo {

  10 < plugin.tx_seodynamictag_pi1

  ...

We set up the three arrays

  1. 10 for the browser title and

  2. 20 for the <meta>-tag description and

  3. 30 for the <meta>-tag keywords.

temp.seo = COA

temp.seo {

  10 < plugin.tx_seodynamictag_pi1

  ...

  20 < plugin.tx_seodynamictag_pi1

  ...

The special value defines the properties.

  10 < plugin.tx_seodynamictag_pi1

  10 {

    # Example for the page title

    special = title

    ...

There are three possibilities:

  1. title

  2. register

  3. no sepcial value

"Title" effects, that the extension is overwriting the browsers <title>-tag. You can use this only for the browser title.

"Register" enables, that the needed value will be stored in a typo3 register and will be used later. We need this for every <meta>-tag in the HTML head.

The waiving of the special value effects, that the needed value will be echoed in the content area of our website. Though this is the default, but it seems to have less sense.

The property "query"

The plugin.tx_seodynamictag_pi1 has the property "query". The syntax of this property is the syntax of SQL.

The typoscript setup code:

    query {

      select = CONCAT(`title`, ': ', `short`)

      from  = `tt_news`

      where  = `uid` = $1 && `deleted` = 0 && `hidden` = 0

      var.1 = tx_ttnews[tt_news]

The property query is very powerful, because you can define variables, which will get a value at runtime.

You can use a variable with any name in your SQL query everywhere.

  1. You have to label the variable with a dollar character ($).

  2. You have to define the array var with an element named with your variable.

  3. Then you have to allocate the global get variable or the global post variable.

In the example above we defined the variable $1 in the where clause (red coloured).

In the array var we defined the variable $1 a second time as the element 1: var.1 (red coloured).

Then we allocate the value of global var tx_ttnews[tt_news] (red coloured).

If you don't know, which GET variables or POST variables are available use the debug mode. The mode will display the array.

    special = title

    debug = 1

    query {

      ...

tt_products

Thank you for understanding, that we don't repeat explanations from above.

If you aren't close with the example tt_news above, please read it first.

Illustration 9: The result

The result on the page with the single view of a product should be:

  1. The browser title is composed of the title (1) and the category (2) of the product.

  1. That the <meta>-tag description (3) is the value of the subtitle (3) field.

  2. That the <meta>-tag keyword (4) is a list of the words "Detalgeräte", the words of the product title (1) and the product category (2).

We need the following typoscript setup:

temp.seo = COA

temp.seo {

  10 < plugin.tx_seodynamictag_pi1

  10 {

    # Example for the page title

    special = title

    query {

      select = CONCAT(product.title, ' (', category.title, ')') as value

      from   = tt_products as product, tt_products_cat as category

      where  = product.uid = $1 AND product.category = category.uid \

               AND product.deleted = 0 AND product.hidden = 0

      var.1 = tx_ttproducts_pi1[product]

   }

  }

  20 < plugin.tx_seodynamictag_pi1

  20 {

    # Example for a meta tag

    special = register

    register = description

    query {

      select = `subtitle`

      from   = `tt_products`

      where  = `uid` = $1 && `deleted` = 0 && `hidden` = 0

      var.1  = tx_ttproducts_pi1[product]

      maxLength = 200

    }

  }

  30 < plugin.tx_seodynamictag_pi1

  30 {

    # Example for a meta tag

    special = register

    register = keywords

    query {

      select = CONCAT('Dentalgerät ', product.title, ' ', category.title) as value

      from   = tt_products as product, tt_products_cat as category

      where  = product.uid = $1 AND product.category = category.uid \

               AND product.deleted = 0 AND product.hidden = 0

      var.1  = tx_ttproducts_pi1[product]

    }

    keywords = 1

    keywords {

      amount        = 10

      minLength     = 8

      positiveList  = CMC, Nokia

    }

  }

}

The temp.seo object ist the last content element of our page.

It has to be the last element, because we have to avoid, that other content elements override our browser page title or our <meta>-tags.

page {

  meta {

    description {

      field  >

      data = register:description

    }

    keywords {

      field >

      data = register:keywords

    }

  }

  10 < styles.content.get

  1000 < temp.seo

}

The setup code is nearly the same like in the section tt_news above (page 3), but the select clause for the browsers page title and the keywords.

    query {

      select = CONCAT('Dentalgerät ', product.title, ' ', category.title) as value

      from   = tt_products as product, tt_products_cat as category

      where  = product.uid = $1 AND product.category = category.uid \

               AND product.deleted = 0 AND product.hidden = 0

Yes, it's possible to link tables!

The result is composed with values of records out of two tables.

Third Party Extension

Thank you for understanding, that we don't repeat explanations from above.

If you aren't close with the example tt_news above, please read it first.

Illustration 10: The result

The result on the page should be:

  1. The browser title is composed of the title (1) and the subtitle (2) of the displayed news.

  1. That the <meta>-tag description (3) is the value of the short (3) field.

  2. That the <meta>-tag keyword (4) is the value of the title (1) and the subtitle (2) of the news.

The setup code is nearly the same like in the section tt_news above (page 3), but we have

  1. a different table name,

  2. different field names

  3. and a different global get variable.

temp.seo = COA

temp.seo {

  10 < plugin.tx_seodynamictag_pi1

  10 {

    # Example for the page title

    special = title

    query {

      select = CONCAT(`article_caption`, ': ', `article_roof`)

      from   = `tx_hptazarticle_list`

      where  = `uid` = $1 && `deleted` = 0 && `hidden` = 0

      var.1  = art

   }

  }

  20 < plugin.tx_seodynamictag_pi1

  20 {

    # Example for a meta tag

    special = register

    register = description

    query {

      select = `article_teaser_short`

      from   = `tx_hptazarticle_list`

      where  = `uid` = $1 && `deleted` = 0 && `hidden` = 0

      var.1  = art

    }

  }

  30 < plugin.tx_seodynamictag_pi1

  30 {

    # Example for the page title

    special = register

    register = keywords

    query {

      select = CONCAT(`article_caption`, ': ', `article_roof`)

      from   = `tx_hptazarticle_list`

      where  = `uid` = $1 && `deleted` = 0 && `hidden` = 0

      var.1  = art

    }

    keywords = 1

    keywords {

      amount        = 10

      minLength     = 8

      positiveList  = taz, BILD, SZ, Zeit, Spiegel

    }

  }

}

You see, that it is very easy to use the SEO dynamic extension for third party extensions.

Keywords Improvement

You can improve your keywords since version 0.0.3.

This is  the process of keyword handling:

  1. Keywords will be counted.

  2. The first words in the meta tag "keywords" will be the most frequented of the words

  3. You are controlling the weight with the frequency of words by repeating a filed in the SQL query.

Example for an SQL query

    ...

    query {

      select = CONCAT(`title`, ' ', `title`, ' ', `title`, ' ', `title`, ' ', `short`)

      ...

    }

The words in the field title will have the fourfold weight than the words in the field short, because the field title is repeated for times in the SQL query.