[TYPO3-english] how to access typoscript constants from PHP

Stephan Schuler Stephan.Schuler at netlogix.de
Mon Aug 19 21:28:02 CEST 2013


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Hey there.

First of all: Stop using PHP_SCRIPT.

According to this Ticket, it's deprecated since ages and has been removed starting 6.0
http://forge.typo3.org/issues/36009

According to one of the first hits searching for "TYPO3 class reference PHP_SCRIPT", it's deprecated since 6.0 and will be removed by 6.2.
http://typo3.org/api/typo3cms/class_t_y_p_o3_1_1_c_m_s_1_1_frontend_1_1_content_object_1_1_content_object_renderer.html#aad1fdb19d96a87095b765af65369d01e

So, whatever you do, stop using PHP_SCRIPT since this will stop working in a couple of days, most likely by one of the next updates you make.

Now to the topic.

I never thought about accessing constants directly. Constants usually aren't meant to be accessed since they never go through any processing. They are simply done by array_merge_overrule with some str_replace magic (constants in constants are allowed).
But the main part of TypoScript, which is advanced processing, is done on the Setup part, not on the Constants part.

You might access $GLOBALS['TSFE']->tmpl->setup for the setup and $GLOBALS['TSFE']->tmpl->constants for constants.

But when you stop using PHP_SCRIPT and start using proper USER and USER_INT, there is a $conf array passed which provies your typoscript setup.

> lib.foo = USER
> lib.foo.userFunc = Tx_MyExtension_Service_MyService->main
> lib.foo.myNiceProperty = ${my.constant.var}

Then your class getsl created, the main method gets called and the $conf array conntains the 'myNiceProperty' key holding the value of your constant.

This is imho the best way to call user funcs and pass constants. But really don't access constants, ever.


Regards,


Stephan Schuler
Web-Entwickler

Telefon: +49 (911) 539909 - 0
E-Mail: Stephan.Schuler at netlogix.de
Website: media.netlogix.de



- --
netlogix GmbH & Co. KG
IT-Services | IT-Training | Media
Neuwieder Straße 10 | 90411 Nürnberg
Telefon: +49 (911) 539909 - 0 | Fax: +49 (911) 539909 - 99
E-Mail: info at netlogix.de | Internet: http://www.netlogix.de

netlogix GmbH & Co. KG ist eingetragen am Amtsgericht Nürnberg (HRA 13338)
Persönlich haftende Gesellschafterin: netlogix Verwaltungs GmbH (HRB 20634)
Umsatzsteuer-Identifikationsnummer: DE 233472254
Geschäftsführer: Stefan Buchta, Matthias Schmidt



________________________________________
Von: typo3-english-bounces at lists.typo3.org [typo3-english-bounces at lists.typo3.org]" im Auftrag von "Erich Specht [erich at erichspecht.com]
Gesendet: Montag, 19. August 2013 20:45
An: typo3-english at lists.typo3.org
Betreff: [TYPO3-english] how to access typoscript constants from PHP

How can I access Typoscript constants (user-defined) from within a PHP
script included via PHP_SCRIPT object?  I can't find them in the $GLOBALS
object and I'm not sure where to find the list of available variables.



Any help pointing me in the right direction would be appreciated!

_______________________________________________
TYPO3-english mailing list
TYPO3-english at lists.typo3.org
http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english

-----BEGIN PGP SIGNATURE-----
Version: PGP Universal 3.3.0 (Build 8741)
Charset: utf-8

wpUDBQFSEnHDpp0IwsibV8MBCN9iBACLEm04JHgaqAlU9nWf8fauVnpgjVAp67YV
klkpxBAOvyJ4OhmO1kIBU8JwHqEvT43Rv+jnke3PysFrLVY9lARUcA97Ju67Pe/Z
wQHei9xJrlDSpDiDWVeG3AXWDoNS9KzGMEm7SqCnFhTudfDErynbIALauvhed3Y3
bnK2SZu9BA==
=g6B9
-----END PGP SIGNATURE-----


More information about the TYPO3-english mailing list