Better Google ranking with WEC Discussion Forum

I found out that my cms-blog was not very high up in the google-rankings. Even if you would search for the exact blog-item title you could still only find me on the 4th page or so. We can do better then this.

So to improve my ranking I wanted to change two things to the default install of the Typo3 WEC Discussion Forum. I wanted the blog title to show in the page title, I want to have the item title in the url and, while we are at it, I want the home-link to link to ‘/’ instead of something like ‘/Home.2.0.html’.

Here we go:

1. Add the blogitem title to the page title

Add this code to the page template of your page that contains the wec plugin. NOTE: do not add this to the root-page of your website!:

config.noPageTitle = 2

page.headerData.20 = TEXT

page.headerData.20.value = Your site title

page.headerData.20.wrap = |

page.headerData.30 = TEXT

page.headerData.30.value = Your Blog title

page.headerData.30.noTrimWrap=| - ||

page.headerData.40 = TEXT

page.headerData.40.value = Overview

page.headerData.40.noTrimWrap=| - ||

page.headerData.50 = TEXT

page.headerData.50.value = 

[globalVar = HTTP_GET_VARS|tx_wecdiscussion|single>0]

page.headerData.40 = CONTENT

page.headerData.40{

  table=tx_wecdiscussion_post

  # wrap the whole element

  wrap=|

  # the SQL-Query

  select{

    max=1

    selectFields=subject

    pidInList = 21

    andWhere.data = global:HTTP_GET_VARS|tx_wecdiscussion|single

    andWhere.wrap = uid='|'

  }

  renderObj=COA

  renderObj{

    5=TEXT

    5{

      noTrimWrap=| - ||

      field=subject

    }

  }

}

What this does, in short, is, if the url contains the ‘single’ get-variable, if queries the wec-table for the item title and add this to the page-title. Simple enough, isn’t?

The inspiration for this trick came from Infohit

2. Give our blog a pretty url (in the single item view)

First install and enable the realurl extension, if you haven’t done so already. The manual describes this well enough.

Then you need to add this code to your existing realurl configuration (in localconfig.conf):

 'postVarSets' => array(

            '_DEFAULT' => array (

                'view' => array(

                    array(

                        'GETvar' => 'tx_wecdiscussion[single]',

                        'lookUpTable' => array(

                            'table' => 'tx_wecdiscussion_post',

                            'id_field' => 'uid',

                            'alias_field' => 'subject',

                            'addWhereClause' => ' AND NOT deleted',

                            'useUniqueCache' => 1,

                            'useUniqueCache_conf' => array(

                                'strtolower' => 1,

                                'spaceCharacter' => '-',

                            ),

                        ),

                    ),

                ),

                'archive' => array(

                    array(

                        'GETvar' => 'tx_wecdiscussion[show_date]',

                    ),

                    array(

                        'GETvar' => 'tx_wecdiscussion[archive]',

                        'valueMap' => array(null => '1'),

                    ),

                ),

            ),

        ),

This code above will give you a url like ‘/cms-blog/view/top-6-of-badly-designed-teamsite-features/’, just what the doctor ordered.

3. Make your home links link to ‘/’

This is not so easy with realurl, unfortunately. You’ll need some php code. :-(

First you need to add this class to an existing (or create new) php-library file, normally located under /fileadmin:

class user_tweakMenu {

    function replace( $I, $conf ) {

        $I[ 'parts' ][ 'ATag_begin' ] = preg_replace(

            '{' . $conf['searchFor'] . '}',

            $conf['replaceWith'] ? $conf['replaceWith'] : "",

            $I[ 'parts' ][ 'ATag_begin' ] );

        return $I;

    }

}

Then, in your template (at the site root level) you’ll need to add this code (customise it to your situation and needs):

includeLibs.include1 = fileadmin/my_include.inc

temp.menu.1{

      IProcFunc = user_tweakMenu->replace

      IProcFunc.searchFor = /home/"

      IProcFunc.replaceWith = /"

}

This trick is well described by Hannes Schmidt

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s