TSref/typolink
TypoScript This page is document in progress.
typolink
Wraps the incoming value with a link (HTML <a> tag).
If typolink is called from parseFunc, the array $cObj->parameters contains the parameters of the link (lowercased keys).
| 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 "no_cache=1" to the generated URL |
- |
| useCacheHash | boolean | If set, the additionalParams list is split to a hash string that is appended to the URL, like &cHash=ae83fd7s87. When the caching mechanism encounters this value, it calculates the same value on the server based on incoming values in $_GET, 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 to the server and non-predictable. |
- |
| additionalParams | string /stdWrap | This is a string that gets appended to the URL (thus, it must start with '&').
Example: '&print=1' '&sword_list[]=word1&sword_list[]=word2' Applications: Useful when linking to pages from a search result. The search words are stored in the register SWORD_PARAMS and can be insert directly like this: .additionalParams.data = register:SWORD_PARAMS NOTE: This is only active for internal links. |
- |
| addQueryString | boolean | Adds the QUERY_STRING to the start of the URLs query string. Doesn't check for duplicate parameters unless "config.uniqueLinkVars" is set to 1.
.method: If set to to GET or POST, the parsed query arguments (GET or POST data) will be used. This settings are useful if you use extensions like RealURL, which translate part of the path into query arguments. .exclude: List of query arguments to exclude from the link (eg L or cHash). |
- |
| wrap | wrap | Wraps the links. |
- |
| ATagBeforeWrap | boolean | If set, the link is first wrapped with ".wrap" and then the <a>-tag. |
- |
| parameter | string /stdWrap |
The data that ->typolink uses to create the link. The value is trimmed. If 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 <nowiki>http://-page
The input is parsed like this: First the parameter is split by space (' ') characters. This provides a way to pass more parameters. See "target" below here.
Now the input can be an alias or page ID. If the input is an integer, it's a page UD, if it's two comma separated integers, it's an ID/type pair, else it's an alias. For page ID's or aliases you can prepend a "#" mark with a number indicating the tt_content record number on the page to jump to. (if the .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. You may override this target by adding the new target after the parameter separated by a whitespace. If the Target parameter is 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 and title as fourth parameter without also setting the target. Open in windows with fixed dimensions (JavaScript) It is possible to open the link in a window 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). If set to -, then it's the same as no class passed to the function. This feature enables you to still pass a title as fourth parameter without setting the class also. Title The title attribute is normally specified via .ATagParams or directly via the .title property. But you may override this value by adding the desired title as the fourth parameter (parameters separated by whitespace) to typolink. 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> </nowiki> |
- |
| title | string /stdWrap | Sets the title parameter of the A-tag. |
- |
| 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", 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 with an <a> tag, 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.
This is used create a link that jumps directly to a section on another page. |
- |
| ATagParams | <A>-params /stdWrap |
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]