TYPO3 Logo
TypoScript in 45 Minutes
Release: master

Loading data.

  • Sitemap
  • 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
  • Targets for Cross-Referencing

PAGE CONTENTS

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

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
  • Contact
  • Issues
  • Repository

Last updated: Nov 22, 2017 23:36

Last rendered: Jan 22, 2021 09:09

TYPO3 Theme 4.4.3

© Copyright since 2004 by the TYPO3 Documentation Team
  • Legal Notice
  • Privacy Policy