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

5.8. typolink:

Wraps the incoming value with link.

If this is used from parseFunc the $cObj->parameters-array is loaded with the link-parameters (lowercased)!

Property:

Data type:

Description:

Default:

extTarget

target /stdWrap

target used for external links

_top

target

target /stdWrap

target used for internal links

no_cache

boolean /stdWrap

Adds a "&no_cache=1"-parameter to the link

useCacheHash

boolean

If set, the additionalParams list is exploded and calculated into a hashstring appended to the url, like “&cHash=ae83fd7s87”. When the caching mechanism sees this value, it calculates the same value on the server based on incoming values in HTTP_GET_VARS, excluding id,type,no_cache,ftu,cHash,MP values. If the incoming cHash value matches the calculated value, the page may be cached based on this.

The [SYS][encryptionKey] is included in the hash in order to make it unique for the server and non-predictable.

additionalParams

string /stdWrap

This is parameters that are added to the end of the url. This must be code ready to insert after the last parameter.

Example:

'&print=1'

'&sword_list[]=word1&sword_list[]=word2'

Applications:

This is very useful when linking to pages from a searchresult. The searchwords are stored in the register-key SWORD_PARAMS and can be insert directly like this:

.additionalParams.data = register:SWORD_PARAMS

NOTE: This is only active for internal links!

addQueryString

boolean

Add the QUERY_STRING to the start of the link. Notice that this does not check for any duplicate parameters! This is not a problem (only the last parameter of the same name will be applied), but enable "config.uniqueLinkVars" if you still don't like it.

wrap

wrap

Wraps the links.

ATagBeforeWrap

boolean

If set, the link is first wrapped with ".wrap" and then the <A>-tag.

parameter

string /stdWrap

This is the data, that ->typolink uses to create the link. The value is trimmed and if it's empty, ->typolink returns the input value untouched.

NOTE: If used from parseFunc, this value should be imported by:

typolink.parameter.data = parameters : allParams

Examples:

Internal links:

integers (51): creates a link to page with uid = 51

filerefs (fileadmin/somedir/thedoc.html): creates a link to the file on the local server.

strings (some_alias):  creates a link to the page with alias = "some_alias"

External links:

email-adresses (name@email.com): creates a link to the email-addr.

domains (www.domain.com): creates link to http://-page

The input is parsed like this:

First the parameter is splitted by character-space. This provides a way to pass more parameters. See "target" below here.

If a "@" is in the string, it's an email

If a period (.) is in the string AND if the period (.) is found before a slash (/) is found OR if a doubleslash is found, then it's a URL

If a slash (/) is found, it's a filereference. If the file/directory does not exist on the server, the link is NOT made!

Now the input can be an alias or page-id. If the input is an integer it's a page-id, if it's two comma separated integers, it's a id/type pair, else it's an alias. For page-id's or aliases you can prepend a "#" mark with a number indication tt_content record number on the page to jump to! (if .section-property is present, it overrides this).

If you insert only "#234" where "234" is the tt_content record number, it links to the current page-id

Target

Target is normally defined by the ".extTarget" and "target" properties of typolink. But you may override this target by adding the new target after the parameter separated by whitespace. Thus the target becomes the 'second' parameter.

If the 'Target' parameter is set to the '-' character, then it's the same as no target passed to the function. This feature enables you to still pass a class as third parameter without setting the target also.

Open in windows with fixed dimensions (JavaScript)

It is possible to open the link in a window opened by JavaScript (with “window.open”). For this, just set the target value to “123x456” where 123 is the window width and 456 is the window height. You can also specify additional parameters to the function by entering them separated from the width and height with a colon “:”. For instance “230x450:resizable=0,location=1” will disable resizing of the window and enable the location bar.

Also see property “JSwindow”.

Class

If you specify a 'third parameter' separated by whitespace in the parameter value this becomes the class-parameter of the link. This class parameter is inserted in the link-tag before any values from .ATagParams which means this class value will override any class value set in ATagParams (at least for MSIE).

Examples of multiparameters:

Consider this .parameter value passed to this function:

51  _blank  blueLink

This would result in a link approx like this:

<A href=”?id=51” target=”_blank” class=”blueLink”>

JSwindow_params

string

Preset values for opening the window. This example lists almost all possible attributes:

status=1,menubar=1,scrollbars=1,resizable=1,location=1,directories=1,toolbar=1

returnLast

string

If set to "url" then it will return the URL of the link ($this->lastTypoLinkUrl)

If set to "target" it will return the target of the link.

So, in these two cases you will not get the value wrapped but the url or target value returned!

section

string /stdWrap

If this value is present, it's prepended with a "#" and placed after any internal url to another page in TYPO3.

This is used create a link, which jumps from one page directly the section on another page.

ATagParams

<A>-params

Additional parameters

Example:

class=”board”

userFunc

function-name

This passes the link-data compiled by the typolink function to a user-defined function for final manipulation.

The $content variable passed to the user-function (first parameter) is an array with the keys “TYPE”,  “TAG”, “url”, “targetParams” and “aTagParams”.

TYPE is an indication of link-kind: mailto, url, file, page

TAG is the full <A>-tag as generated and ready from the typolink function.

The latter three is combined into the 'TAG' value after this formula:

<A HREF="'.$finalTagParts["url"].'"'.$finalTagParts["targetParams"].$finalTagParts["aTagParams"].'>

The userfunction must return an <A>-tag.

[tsref:->typolink]