TYPO3 Logo
TypoScript in 45 Minutes
Release: 10.4

Loading data.

  • Introduction
  • TypoScript - A quick overview
    • Backend configuration
    • Prerequisites
    • Why TypoScript?
    • The main template
    • The term template
    • TypoScript is just an array
    • First steps
  • Reading content records
    • The various content elements
  • Create a menu
  • Insert content in a HTML template
  • Using fluid_styled_content
  • TypoScript objects
    • Objects executing database queries
    • Objects rendering content
    • Further objects
  • TypoScript functions
    • imgResource
    • select
    • split
    • if
    • typolink
    • parseFunc
  • Using stdWrap correctly
    • Heed the order
    • Modify the order
    • The data type
    • cObject
  • Using the getText data type
  • Next steps
  • Sitemap
  • Index

PAGE CONTENTS

  • typolink
  1. Start
  2. TypoScript functions
  3. typolink
View source How to edit Edit on GitHub

Display settings


Color scheme of code blocks:


typolink¶

typolink is the TYPO3 CMS function that allows us to generate all kinds of links. If possible one should always use this function to generate links as they will be processed by TYPO3 CMS. This is a prerequisite, for example, for the "realurl" extension to generate speaking URLs or for the anti-spam protection of email addresses.

Please resist the urge to a straight <a href="...">...</a> construct in your templates.

Basically typolink links the specified text according to the defined parameters. One example:

temp.link = TEXT
temp.link {

    # This is the defined text.
    value = Example link

    # Here comes the typolink function.
    typolink {

        # This is the destination of the link...
        parameter = http://www.example.com/

        # with a target ("_blank" opens a new window)...
        extTarget = _blank

        # and add a class to the link so we can style it.
        ATagParams = class="linkclass"
    }
}

The example above will generate this HTML code:

<a class="linkclass" target="\_blank" href="http://www.example.com/">Example link</a>

typolink, in a way, almost works like a wrap: the content which is defined for example by the value property, will be wrapped by the HTML anchor tag. If no content is defined, it will be generated automatically. With a link to a page, the page title will be used. With an external URL, the URL will be shown.

The above example can actually be shortened, because the parameter property can take a series of values separated by a white space:

temp.link2 = TEXT
temp.link2 {

    # Again the defined text.
    value = Example link

    # The parameter with the summary of the parameters of the first
    # example (explanation follows below).
    typolink.parameter = www.example.com _blank linkclass
}

The exact syntax for parameter property is fully described, as usual, in the TypoScript Reference.

It is even possible to define links that open in JavaScript popups:

temp.link = TEXT
temp.link {

     # The link text.
     value = Open a popup window.

     stdWrap.typolink {
          # The first parameter is the page ID of the target page,
          # second parameter is the size of the popup window.
          parameter = 10 500x400

          # The title attribute of the link.
          title = Click here to open a popup window.

          # The parameters of the popup window.
          JSwindow_params = menubar=0, scrollbars=0, toolbar=0, resizable=1

     }
}
  • Previous
  • Next
  • Home
  • Contact
  • Issues
  • Repository

Last updated: Feb 25, 2023 10:41

Last rendered: Feb 25, 2023 10:42

  • TYPO3 Theme 4.7.9
  • DRC v3.0.dev30
© Copyright since 2012 by the TYPO3 contributors
  • Legal Notice
  • Privacy Policy
  • Code of Conduct