Skip to content

Commit 5e1eefc

Browse files
Improve hint regarding unavailable variables (#1553)
* Improve hint regarding unavailable variables * Apply suggestions from code review --------- Co-authored-by: Lina Wolf <48202465+linawolf@users.noreply.github.com>
1 parent 3656a5c commit 5e1eefc

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Documentation/Conditions/Index.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,9 @@ traverse()
792792
# Traverse query parameters of current request along tx_news_pi1[news]
793793
[request && traverse(request.getQueryParams(), 'tx_news_pi1/news') > 0]
794794
795+
# Traverse page properties for current page
796+
[traverse(page ?? [], "pid") == 65]
797+
795798
.. tip::
796799
Checking for the :ref:`request object <t3coreapi:typo3-request>` to be
797800
available before using :typoscript:`traverse()` may be necessary, for
@@ -801,6 +804,9 @@ traverse()
801804
available). This avoids the error
802805
`Unable to call method "getQueryParams" of non-object "request"`.
803806

807+
Same is true for the `page` variable, which might not be available
808+
in all contexts, for example backend modules without a page.
809+
One can use the `?? []` workaround.
804810

805811
.. index:: Conditions; compatVersion
806812
.. _condition-function-compatVersion:

0 commit comments

Comments
 (0)