linkhandler extension (a christmas gift)

Did you also have costumers asking things like "How can I link to a news?" or "I want to link to products"...?

Well now you can answer this question easy with: "Of course linking to news is as easy as linking to a page.".

Extension linkhandler

This extension enables linking to any record by doing the following:

  • adding Tabs to the link browser in the Backend
  • enables typolink configuration to define how the links should be build for the frontend.
  • comes with a patch for TYPO3 4.1.x

Using the linkhandler to link to tt_news:

  1. Be sure you have the requirements: TYPO3 >4.1 ; PHP 5
  2. download and install the extension
  3. If you run TYPO3 4.1.x you have to check the checkbox to activate the patch!
  4. Edit the TSConfig in the pageproperties of your rootpage.
  5. Edit the typoscript settings for your page.
  6. ..read the manual for details

Edit the TSConfig in the pageproperties of your rootpage:

The extension comes per default with a tab "News". So if you are fine with that - there is no need to adjust anything. However this is the default definition:

RTE.default.tx_linkhandler { 
    tt_news {       
        label=News
        listTables=tt_news
    }
}

mod.tx_linkhandler {   
    tt_news {       
        label=News
        listTables=tt_news       
    }   
}

Edit the typoscript settings for your page:

The extensio comes also with default typoscript configuration for tt_news. To load this you have to add the "linkhandler" static typoscript to your template.

Also you have to adjust the constant and set your single Pid.

linkhandler.newsSinglePid=**

By the way here is the default typoscript:

plugin.tx_linkhandler {
    tt_news {
            parameter={$linkhandler.newsSinglePid}
            additionalParams=&tx_ttnews[tt_news]={field:uid}
            additionalParams.insertData=1    
            useCacheHash=1
    }
}

technical background

Since version 4.2 there is a new HOOK in the core - the first hook which is based on a PHP5 interface class. With the help of this hook you can add Tabs to the linkbrowser (both: the classic and the htmlarea RTE one).

The extension provides a way to define additional Tabs with TSConfig. The link to records are stored in the database in the format: record:<tablename>:<ui>

Since TYPO3 4.2 there is a new working feauture called linkhandler: An extension can register to handle links which begin with a certain key.

The extension linkhandler registers for the key "record" and therefore handles the building of links to records. The links itself are defined with a typolink object - with the trick that the typolink is loaded with the full datarow of the record.

 

blog comments powered by Disqus
  1. Maxime 27.01.10 17:18

    Many thanks to you Daniel and to GrG, your both codes were very useful(and also save my day).

  2. Daniel P 04.03.09 20:55

    The external url field (in pages) is not processed by typolink - therefore this cannot work.

  3. GrG 03.03.09 02:53

    guten tag Dan,

    Another question maybe trickier : When I create a tt_news article and I select "external link" as type, I then select the link and choose a tt_news...

    I then obtain in the external url field this kind of stuff (logical 'til now :record:tt_news:3993 )

    But, when I display the article on the FE... The link is not translated ! It remains record:tt_news:3993 ..; And I don't understand why ! It should pass by your code ? What do I have to do to fix it ?

  4. GrG 02.03.09 08:34

    Hi Daniel and thanks for your precious help. Here is the code that did the trick for me :

    plugin.tx_linkhandler {
    tt_news {
    parameter.cObject=CASE
    parameter.cObject {
    key.field=pid
    560=TEXT
    560.value = 561
    default = TEXT
    default.value = 14
    }
    additionalParams=&tx_ttnews[tt_news]={field:uid}&tx_ttnews[backPid]={TSFE:id}
    additionalPara[..]
    useCacheHash=1
    title={field:title}
    title.insertData=1
    }
    }

  5. Daniel P http://www.typo3-media.com 02.03.09 07:33

    Hey. Try using the CASE TS-Object:

    parameter.cObject=CASE
    parameter.cObject.key.field=pid
    parameter.cObject.100=101
    pa[..] tried - but somethig like this should work.

  6. grg 01.03.09 22:17

    Hi,

    and thanks for this good tutorial. I encounter a typoscript problem here : I want to set the parameter value depending on the {field:pid}.

    If the value of this field is 100, i want to put parameter = 101
    If the value of {field:pid}=200, I want to set parameter = 201

    i've spent 1 day long trying to solve it without success...

    Any clue ?

  7. Tommy http://www.lightwerk.com 27.12.07 10:09

    For Backlinks extend the line
    additionalParams=&tx_ttnews[tt_news]={field:uid}&tx_ttnews[backPid]={TSFE:id}

blogroll