Documentation · ViewHelper reference

Link / PageViewHelper


A view helper for creating links to TYPO3 pages.

Examples

link to the current page

<f:link.page>page link</f:link.page>

Output

page link</f:link.action>
(depending on the current page and your TS configuration)

query parameters

<f:link.page pageUid="1" additionalParams="{foo: 'bar'}">page link</f:link.page>

Output

page link</f:link.action>
(depending on your TS configuration)

query parameters for extensions

<f:link.page pageUid="1" additionalParams="{extension_key: {foo: 'bar'}}">page link</f:link.page>

Output

page link</f:link.action>
(depending on your TS configuration)

/
  • Tag usage example

    <f:link.page additionalAttributes="{foo: 'bar'}" data="{foo: 'bar'}" pageUid="[anySimpleType]" additionalParams="{foo: 'bar'}" pageType="123" noCache="1" noCacheHash="1" section="''" linkAccessRestrictedPages="1" absolute="1" addQueryString="1" argumentsToBeExcludedFromQueryString="{foo: 'bar'}" addQueryStringMethod="NULL" class="NULL" dir="NULL" id="NULL" lang="NULL" style="NULL" title="NULL" accesskey="NULL" tabindex="123" onclick="NULL" target="NULL" rel="NULL">
    	<!-- tag content - may be ignored! -->
    </f:link.page>
  • Inline usage example

    {f:link.page(additionalAttributes: {foo: 'bar'}, data: {foo: 'bar'}, pageUid: [anySimpleType], additionalParams: {foo: 'bar'}, pageType: 123, noCache: 1, noCacheHash: 1, section: '''', linkAccessRestrictedPages: 1, absolute: 1, addQueryString: 1, argumentsToBeExcludedFromQueryString: {foo: 'bar'}, addQueryStringMethod: 'NULL', class: 'NULL', dir: 'NULL', id: 'NULL', lang: 'NULL', style: 'NULL', title: 'NULL', accesskey: 'NULL', tabindex: 123, onclick: 'NULL', target: 'NULL', rel: 'NULL')}

Arguments

Argument Description Type
absolute

If set, the URI of the rendered link is absolute

boolean
accesskey

Keyboard shortcut to access this element

string
addQueryString

If set, the current query parameters will be kept in the URI

boolean
addQueryStringMethod

Set which parameters will be kept. Only active if $addQueryString = TRUE

string
additionalAttributes

Additional tag attributes. They will be added directly to the resulting HTML tag.

array
additionalParams

query parameters to be attached to the resulting URI

array
argumentsToBeExcludedFromQueryString

arguments to be removed from the URI. Only active if $addQueryString = TRUE

array
class

CSS class(es) for this element

string
data

Additional data-* attributes. They will each be added with a "data-" prefix.

array
dir

Text direction for this HTML element. Allowed strings: "ltr" (left to right), "rtl" (right to left)

string
id

Unique (in this file) identifier for this HTML element.

string
lang

Language for this element. Use short names specified in RFC 1766

string
linkAccessRestrictedPages

If set, links pointing to access restricted pages will still link to the page even though the page cannot be accessed.

boolean
noCache

set this to disable caching for the target page. You should not need this.

boolean
noCacheHash

set this to suppress the cHash query parameter created by TypoLink. You should not need this.

boolean
onclick

JavaScript evaluated for the onclick event

string
pageType

type of the target page. See typolink.parameter

integer
pageUid

target page. See TypoLink destination

anySimpleType
rel

Specifies the relationship between the current document and the linked document

string
section

the anchor to be added to the URI

string
style

Individual CSS styles for this element

string
tabindex

Specifies the tab order of this element

integer
target

Target of link

string
title

Tooltip text of element

string
Required attribute

Revision history

commit 27bbf6507db26ae9d53054ce908df203beefc3c8
Author: Bastian Waidelich <[email protected]>
Date:   Sat May 16 18:43:53 2009 +0000

    tx_fluid:
     * !!!changed view helpers once again!!! link view helpers reside in the link subfolder now. For each link view helper there is a corresponding uri helper now. Check out https://svn.typo3.org/TYPO3v4/CoreProjects/MVC/viewhelpertest for a working example.
     * TagBuilder->setContent does not apply htmlspecialchar() on the the tag contents, as that does not really makes sense - if you really need to escape tag contents, you gotta do it yourself now.

commit 8e91de1cb92b371c72dab359e7b72da8639728dc
Author: Bastian Waidelich <[email protected]>
Date:   Mon May 18 08:31:44 2009 +0000

    Fluid:
    * Removed debug output from Tx_Fluid_ViewHelpers_Uri_ActionViewHelper.
    * Controller-Fallback is not required anymore, it is done in the URIHelper of Extbase
    * Tx_Fluid_ViewHelpers_Link_PageViewHelper now uses the URIHelper directly instead of referring to the corresponding URI ViewHelper

commit 50af6b9c08d04e3e1d4ce56a499a9a3d4b84efc3
Author: Sebastian Kurfürst <[email protected]>
Date:   Thu May 28 21:45:46 2009 +0000

    Fluid:
    * Backported major changes from Fluid v5 to Fluid v4
    * !!! Many of these changes are not backwards-compatible! Please read this if you have written custom ViewHelpers!
    * Introduced Shorthand Syntax for calling ViewHelpers
    * Core:
    ** Lots of internal cleanup and refactorings.
    ** !!! Complete restructuring into subpackages.
    * ViewHelpers:
    ** !!! The base classes of ViewHelpers changed to Tx_Fluid_Core_ViewHelper_AbstractViewHelper and Tx_Fluid_Core_ViewHelper_TagBasedViewHelper. Please adjust your ViewHelpers!
    ** !!! $this->variableContainer has been renamed to $this->templateVariableContainer
    ** !!! the view is not in $this->variableContainer anymore. Currently there is no way to fetch the View from a ViewHelper.
    ** Introduced a new $this->controllerContext containing the context variables of the controller
    ** !!! The request can be now found in $this->controllerContext->getRequest()
    ** !!! The URIHelper has been renamed to URIBuilder and can be now found in $this->controllerContext->getURIBuilder()
    ** Introduced a new ViewHelperVariableContainer, available in $this->viewHelperVariableContainer to pass data between ViewHelpers. Should only be needed in very rare cases.
    ** !!! Removed <f:format.htmlEscape> ViewHelper! Please remove these declarations in your template! Escaping of object accessors is now automatically done, see next point.
    * !!! ObjectAccessors {...} are now automatically HTMLspecialChar'd if not used as an argument to a ViewHelper. This is done using a new ObjectAccessorPostProcessor. Lateron, this will be made configurable.

commit ebb9b4b164e99fe7f9d3cd95af6f464f6f6ca846
Author: Bastian Waidelich <[email protected]>
Date:   Mon Aug 31 19:10:20 2009 +0000

    [FEATURE] Fluid (ViewHelpers): Backported checkbox & radio form viewHelpers from Fluid
    [-BUGFIX] Fluid (ViewHelpers): Removed unused "options"-argument from formViewHelper
    [+FEATURE] Fluid (ViewHelpers): Added "actionUri"-argument to formViewHelper which allows to explicitly set the forms action attribute
    [~TASK] Fluid (ViewHelpers): Adapted viewHelpers to latest changes of UriBuilder (Extbase revision 1179)
    [~BUGFIX] Fluid (ViewHelpers): SubmitViewHelper now correctly extends Tx_Fluid_ViewHelpers_Form_AbstractFormFieldViewHelper
    [-TASK] Fluid (Tests): Removed obsolete file ViewHelperBaseTestcase_testcase.php

commit f5ec0187ec2ad9fc06fa5f1439bc183a917295b5
Author: Bastian Waidelich <[email protected]>
Date:   Fri Sep 4 16:08:17 2009 +0000

    [+FEATURE] Fluid (ViewHelpers): added "format" argument to action- and page-viewHelpers. Now you can create links like "<f:link.action format="xml" />"
    [~TASK] Fluid (Tests): Adapted ViewHelperBaseTestcase to the latest Exbase changes

commit d06704ca58ad5902f6bb4ce146024f41e5ba5aad
Author: Sebastian Kurfürst <[email protected]>
Date:   Sun Sep 13 18:59:22 2009 +0000

    [+BUGFIX] Fluid: Fixed fatal error and missing uid to __identifier conversion.

commit 8ffc97e1d5c5e4e422b88b480836a1a56f7ca9e9
Author: Sebastian Kurfürst <[email protected]>
Date:   Tue Mar 16 10:56:16 2010 +0000

    [+TASK] Fluid (ViewHelpers): Improved Documentation in *PageViewHelper. Thanks to Falk Kühnel for the suggestion! Resolves #6297.

commit 186bdaeac89820779f91853b830cc95d60c7ad58
Author: Bastian Waidelich <[email protected]>
Date:   Tue Jul 13 09:42:26 2010 +0000

    [-TASK] Fluid: [email protected] annotation from all Fluid classes to ease the backporting process. Relates to #8835 (backported from Fluid package)

commit 1d36de6ed90007e324b773782e8f0a1d1c1191a2
Author: Bastian Waidelich <[email protected]>
Date:   Tue Jul 13 10:12:30 2010 +0000

    [-TASK] Fluid: [email protected][email protected] annotations from all Fluid classes. They have already been removed in FLOW3 packages in r2813.

commit 2bd9f56a7a820e303cc9ad9900557edb677136a8
Author: Bastian Waidelich <[email protected]>
Date:   Tue Jul 13 14:17:07 2010 +0000

    [+BUGFIX] Fluid: Replaced SplObjectStorage by Tx_Extbase_Persistence_ObjectStorage to be PHP 5.2-compatible (which ships with a broken implementation of SplObjectStorage)
    [!!!][~TASK] Fluid (Core): Renamed ConditionViewHelper and TagBasedViewHelper to Abstract*ViewHelper as per CGL. (backported from Fluid package r4840). To be backwards-compatible, TagBasedViewHelper.php still exists and will write an entry to TYPO3s deprecation log if used. Please adapt your custom ViewHelpers and inherit from AbstractTagBasedViewHelper instead of TagBasedViewHelper. This resolves #8834
    [~TASK] Fluid: Marked vfs unit tests to be skipped, as vfs is not part of v4 (yet)

commit 472451987ca0530fa5828bb0b79fcafa2f905a35
Author: Bastian Waidelich <[email protected]>
Date:   Fri Nov 19 20:58:09 2010 +0000

    [-TASK] Fluid: [email protected] annotations as they are not used in v4

commit dd8928aed4c119d8db37322acb91ded24ba5cc35
Author: Bastian Waidelich <[email protected]>
Date:   Thu Dec 30 16:21:11 2010 +0000

    [+TASK] Fluid (ViewHelpers): Fix, cleanup and extend inline documentation of ViewHelpers
    
    Resolves #10908

commit fd09d197fa8886b97cb20aa9573f39cd08ce989e
Author: Bastian Waidelich <[email protected]>
Date:   Thu Nov 10 18:27:58 2011 +0100

    [TASK] [email protected] annotations
    
    This backports three recent changes of the TYPO3.Fluid package:
    - [email protected] annotation from files (290f4f5)
    - Simplify license header in PHP files (14bacba)
    - [email protected] tags from source code (9c2e837)
    
    This should not contain any functional change!
    
    Change-Id: I9376dca4af78c4f0f82413011d115b8ad04634dd

commit ec3891d8d4e339d8319428211207e6201be9fd73
Author: Thomas Maroschik <[email protected]>
Date:   Wed Oct 17 21:18:26 2012 +0200

    [TASK][WIP] Move non class code back to source files
    
    Change-Id: I620d2e61860142cdc89cc83474c95542799961c0

commit 554e8f890dcc0dd86a27518b58e2b54be26fd37e
Author: Thomas Maroschik <[email protected]>
Date:   Wed Oct 17 22:20:17 2012 +0200

    [TASK] Namespace classes
    
    Change-Id: Ia7432e1c923826ed58206bca15fb94509adbd508

commit 9d46e6932d35c79bf87c96fa38b8e537c4192f23
Author: Alexander Schnitzler <[email protected]>
Date:   Tue Nov 20 16:27:02 2012 +0100

    [CLEANUP] Adjust code to CGL and fix small namespace bugs
    
    * whitespaces, tabs and blank line issues
    * bool -> boolean
    * int -> integer
    * fix wrong namespace annotations
    
    Fixes: #43157
    Releases: 6.0
    Change-Id: I8397948e19248db029d8efd1555ee56e4982742d
    Reviewed-on: http://review.typo3.org/16619
    Reviewed-by: Helmut Hummel
    Tested-by: Helmut Hummel

commit ba9e4530a025e802d6f62ca9b5861c128458a6b3
Author: Anja Leichsenring <[email protected]>
Date:   Sat Aug 3 15:38:46 2013 +0200

    [BUGFIX] Fix empty href parameter
    
    In case the link target is not available (maybe hidden), the behaviour
    known from the Core is to render the link text, but no a tag. The pageVH
    renders the link, but the href parameter will be empty.
    
    Resolves: #50751
    Releases: 6.2, 6.1, 6.0
    Change-Id: I526aa0e3d42f8aba867b3f996bac2366dc1f6d19
    Reviewed-on: https://review.typo3.org/22789
    Reviewed-by: Wouter Wolters
    Tested-by: Wouter Wolters

commit 77f29a3c69a7cbb27b34072754aa503bace6c9f1
Author: Christian Kuhn <[email protected]>
Date:   Tue Oct 1 14:40:56 2013 +0200

    [TASK] Remove closing PHP tags
    
    Change-Id: Iaa92566c53301e49396fc9fb26b0b339c48d567b
    Resolves: #52360
    Releases: 6.2
    Reviewed-on: https://review.typo3.org/24212
    Reviewed-by: Christian Kuhn
    Tested-by: Christian Kuhn
    Reviewed-by: Ernesto Baschny
    Tested-by: Ernesto Baschny
    Reviewed-by: Anja Leichsenring
    Tested-by: Anja Leichsenring

commit c5b84cd8a3d26aa4c42dbdf10c80883010cc44ce
Author: Stanislas Rolland <[email protected]>
Date:   Fri Jul 19 15:31:09 2013 -0400

    [FEATURE] uriBuilder should honor POST arguments for addQueryString
    
    Currently the addQueryString option in the uriBuilder only supports
    arguments which are in the query string. Therefore, the pagination
    widget does not work with filtering post requests.
    
    Solution: Add addQueryStringMethod (already supported by typolink
    configuration) as property of uriBuilder and as argument of the
    following fluid view helpers:
    * link.action
    * link.page
    * uri.action
    * uri.page
    * widget.link
    * widget.uri
    * widget.pagination
    Add addQueryStringMethod as configuration option of the paginate widget.
    
    Fixes: #35281
    Fixes: #11441
    Releases: 6.2
    Change-Id: I8f2963fa7467dffcf3b9535d2a41820de8f9930a
    Reviewed-on: https://review.typo3.org/22432
    Reviewed-by: Anja Leichsenring
    Tested-by: Anja Leichsenring
    Reviewed-by: Stefano Cecere
    Reviewed-by: Stefan Neufeind
    Reviewed-by: Christian Kuhn
    Tested-by: Christian Kuhn

commit de27a20afbd8f413f60029afc5622c7b33212322
Author: Markus Klein <[email protected]>
Date:   Sun Feb 23 11:21:20 2014 +0100

    [CLEANUP] Replace strlen() with === for zero length check
    
    It is faster to compare a string with === '' to find out if it's empty
    than to run strlen() on it.
    
    The replacement rules are applied as follows:
     *    if (strlen($str))
       => if ((string)$str !== '')
     *    if (!is_string($str) || strlen($str) === 0)
       => if (!is_string($str) || $str === '')
     * If it can be seen easily that $str is a string,
       the typecast is omitted.
    
    Resolves: #54091
    Releases: 6.2
    Change-Id: I59c5cbccea4f98b8f282377e6aa67d970859a457
    Reviewed-on: https://review.typo3.org/27091
    Reviewed-by: Stefan Neufeind
    Tested-by: Stefan Neufeind

commit 945911006229524d55cb48f1f7de0898be9a7b7f
Author: Stefan Neufeind <[email protected]>
Date:   Sun Feb 23 12:34:13 2014 +0100

    Revert "[CLEANUP] Replace strlen() with === for zero length check"
    
    This reverts commit de27a20afbd8f413f60029afc5622c7b33212322
    
    Change-Id: I078d2f7bbff605c91d83a9853e8feb9c31d57ccc
    Reviewed-on: https://review.typo3.org/27792
    Reviewed-by: Stefan Neufeind
    Tested-by: Stefan Neufeind