質問

I am currently trying to add the username of the currently logged in FE user as a constant. I have tried the following but it does not seem to work.

Username = TSFE:fe_user|user|username

I am using this as a starting point

I would like to know how get the FE username into a constant so I can call it when ever I need for the rest of my typoscript.

This is the bit of typoscript that I am trying to get the username into, at the moment it just adds the company name which is defined as a constant else where, but I would like to add int he username also. I have tried adding the global variable for the username but no joy.

[usergroup = *]
config.tx_we_google_analytics {
        _setCustomVar = 1, 'Client', '{$companyName} - {TSFE:fe_user|user|username}',2
        }
[end]

Many Thanks in Advance

Bob

役に立ちましたか?

解決

I wouldn't recommend using an extension to insert something as basic as a Google Analytics Snippet. Each extension slows down the system and makes it less maintainable.

I don't know what your customVar does, but you might try something like

temp.analytics = COA
temp.analytics {

  10 = TEXT
  10.value (
    first part of GA snippet
  )

  20 = TEXT
  20.data = TSFE:fe_user|user|username

  30 = TEXT
  30.value (
     rest of GA Snippet
  )

}

Then insert your snippet where you want, e.g. headerData.99 < temp.analyticsand you're done.

Or even try with a wrap and insertData=1.

As Artur says, if data doesn't render in .wrap, always try stdWrap.wrap - it tends to add functionality (although afaik there have been efforts to pass every wrap through stdWrap by default, but I don't think it's fully implemented).

他のヒント

You can use the appropriate global variable inside TypoScript setup directly, there is no need for a constant I think. The example you provided is the global variable I am talking about, which you can use in any getText context inside typoscript setup.

e.g.

temp.userName = TEXT
temp.userName.data = TSFE:fe_user|user|username

TypoScript constants allow only direct value assignment, it is not possible to assign any other "variable" to a constant IMHO.

Try this. If you are lucky it could work.

[usergroup = *]
config.tx_we_google_analytics {
    _setCustomVar.cObject = TEXT
    _setCustomVar.cObject.value = 1, 'Client', '{$companyName} - {TSFE:fe_user|user|username}',2
    _setCustomVar.cObject.insertData = 1
}
[end]

If it doesn't, you will have to modify the plugin code to process the config value by stdWrap. Thsi code works from within the plugin controller

$configValue = $this->cObj->stdWrap('',$GLOBALS['TSFE']->tmpl->setup['config.']['tx_we_google_analytics.']['_setCustomVar.']);

or simpler (stil within the controller)

$configValue = $this->cObj->stdWrap('',$this->conf['_setCustomVar.']);
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top