I want to call base-url for my custom TYPO3 backend module extension. Is there any built in function for that. If not how to configure one constant and call it?
Any Ideas please share.
Note:I'm using TYPO3. 6.2.9
Found this as a workaround:
The function is trying to get the baseURL set in config.baseURL.
If the baseurl isn't set in the typoscript setup it will use "$_SERVER['SERVER_NAME']" as base.
Maybe it will help..
function loadTS($pageUid) {
$backendUtility = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Utility\\BackendUtility');
$rootLine = $backendUtility->BEgetRootline($pageUid);
$TSObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\TypoScript\\TemplateService');
$TSObj->tt_track = 0;
$TSObj->init();
$TSObj->runThroughTemplates($rootLine);
$TSObj->generateConfig();
return $TSObj->setup;
}
$TS = $this->loadTS('1');
!$TS['config.']['baseURL'])
{
$baseURL = 'http://'.$_SERVER['SERVER_NAME'].'/';
}
else
{
$baseURL = $TS['config.']['baseURL'];
}
Related
I want to call a simple PHP script with typoscript to print the results of it.
I tried this,
lib.doSomething = USER
lib.doSomething {
userFunc = fileadmin/pcoShowBlog.inc.php
}
page.20.marks.kumulierterInhalt < lib.doSomething
What is wrong in this case?
Update
also tried this:
lib.obj = USER
lib.obj.includeLibs = fileadmin/pcoShowBlog.inc.php
lib.obj.userFunc = Blog->showBlog
page.20.marks.kumulierterInhalt < lib.obj
and this:
page.10 = USER_INT
page.10 {
userFunc = In2code\MyUserFuncs\Blog->showBlog
}
page.20.marks.kumulierterInhalt = page.10.userFunc
You should not have any PHP files in fileadmin (security)!
Use an own extension and give the class and method name to the userFunc.
lib.doSomething.userFunc = Vendor\ExtensionName\UserFunc\ShowBlog->methodName
I work on TYPO3 10.4
I wanted to run function from my controller before frontend login, so I created my plugin and put it above felogin plugin.
For call function from my controller I use typoscipt like this:
lib.doSomething = USER
lib.doSomething {
userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
extensionName = extName
vendorName = vendor
pluginName = plugin
}
In template I just put
<f:cObject typoscriptObjectPath="lib.doSomething"/>
Problem can appears with more then one function in controller, because switchableControllerActions is deprecated, I suggest this solution: https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/10.3/Deprecation-89463-SwitchableControllerActions.html
I was using fluidpages for template building, and would like to choose the template dynamically based on a field in the fe_users table. For example, most people will see the EXT:default template by default, while some will see EXT:advanced template instead, as they are marked as special.
I tried
plugin.tx_template {
view {
templateRootPaths {
0 = EXT:default/Resources/Private/Templates/
10 {
data = TSFE:fe_user|user|template
wrap = EXT: | /Resources/Private/Templates/
}
}
}
}
But it seems the TS is not parsed and is used directly by fluid, therefore failed.
Any idea or hint is appreciated!
Actually this may be possible. But i can't see an obvious way on how to override the chosen template in the page properties.
To my knowledge, you are required to select a template in the page record.
If you find a possibility to override that one, you could use a TS Setup like this:
EXT:template_package/Configuration/TypoScript/constants.txt:
plugin.tx_templatepackage {
view {
templateRootPaths.default = EXT:template_package/Resources/Private/Templates/
partialRootPaths.default = EXT:template_package/Resources/Private/Partials/
layoutRootPaths.default = EXT:template_package/Resources/Private/Layouts/
}
}
EXT:template_package/Configuration/TypoScript/setup.txt:
plugin.tx_templatepackage {
view {
templateRootPaths.default = {$plugin.tx_templatepackage.view.templateRootPaths.default}
partialRootPaths.default = {$plugin.tx_templatepackage.view.partialRootPaths.default}
layoutRootPaths.default = {$plugin.tx_templatepackage.view.layoutRootPaths.default}
}
}
Above part will setup your global paths.
After that, you'll define your sub packages for templates.
EXT:template_package/Configuration/TypoScript/Basic/setup.txt
plugin.tx_templatepackage {
view {
templateRootPaths.10 = {$plugin.tx_templatepackage.view.templateRootPaths.0}Basic/
partialRootPaths.10 = {$plugin.tx_templatepackage.view.partialRootPaths.0}Basic/
layoutRootPaths.10 = {$plugin.tx_templatepackage.view.layoutRootPaths.0}Basic/
}
}
And
EXT:template_package/Configuration/TypoScript/Advanced/setup.txt
plugin.tx_templatepackage {
view {
templateRootPaths.20 = {$plugin.tx_templatepackage.view.templateRootPaths.0}Advanced/
partialRootPaths.20 = {$plugin.tx_templatepackage.view.partialRootPaths.0}Advanced/
layoutRootPaths.20 = {$plugin.tx_templatepackage.view.layoutRootPaths.0}Advanced/
}
}
Of course you should make them available within TYPO3:
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile($_EXTKEY, 'Configuration/TypoScript', 'Template Package: Base');
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile($_EXTKEY, 'Configuration/TypoScript/Basic', 'Template Package: Basic');
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile($_EXTKEY, 'Configuration/TypoScript/Advanced', 'Template Package: Advanced');
After all of that, you could override a value — IDK which one — via:
[usergroup = group1-uid]
// override option, which defines the default template
[usergroup = group2-uid]
// override option, which defines the default template
Sorry I can't help you out any further. I tried to dig deeper into EXT:flux and EXT:fluidpages. But i can't see that option.
I am using a custom plugin and I need to add the page title as one of the plugin's settings variables:
plugin.tx_fsearch {
settings {
resultsPath = search-results/brand/{field:title}/make/{field:title}
resultsPath.insertData = 1
}
}
However this is outputting the word 'Array' instead of the path I need.
Does anyone know how I might be able to make this work?
There is no stdWrap available for settings in extbase extensions, no matter if using TEXT cObj or insertData!
As a workaround, you can fix that yourself by doing something like EXT:news does here https://github.com/georgringer/news/blob/master/Classes/Controller/NewsController.php#L495
public function injectConfigurationManager(
\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface $configurationManager
) {
$this->configurationManager = $configurationManager;
$typoScriptService = GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Service\TypoScriptService::class);
$typoScriptArray = $typoScriptService->convertPlainArrayToTypoScriptArray($originalSettings);
$stdWrapProperties = GeneralUtility::trimExplode(',', $originalSettings['useStdWrap'], true);
foreach ($stdWrapProperties as $key) {
if (is_array($typoScriptArray[$key . '.'])) {
$originalSettings[$key] = $this->configurationManager->getContentObject()->stdWrap(
$originalSettings[$key],
$typoScriptArray[$key . '.']
);
}
}
}
$this->settings = $originalSettings;
}
Or you skip the TS part and call the stdWrap directly in your controller.
Try TEXT object
plugin.tx_fsearch {
settings {
resultsPath = TEXT
resultsPath.value = search-results/brand/{field.title}/make/{field.title}
}
}
As dokumented in api.typo3.org the content parameter of Bootstrap->run is not used.
I need a way to process exactly this content within an extbase extension.
The extension is called by:
page = PAGE
page {
stdWrap {
htmlSpecialChars = 0
postUserFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
postUserFunc {
extensionName = MyExtension
pluginName = Pi1
controller = Firstcontroller
vendorName = MyCompany
action = list
}
}
......
How can I access the (postuserfunc-)content?
I tried to use the ContentObject, but couldn't find the content anywhere.
$this->configurationManager->getContentObject()
Is there a workaround?
Cheers
Wirsing
I'm assuming you want to get at the cObject record? You're almost there:
$contentRecord = $this->configurationManager->getContentObject()->data;
Im very new to cake and the plugin (facebook plugin from webtechnick).
what is the best way (easy, effective) to save the user data (facebook_id, token, etc), when (or after?) users logging in?
I tried to use afterFacebookLogin with the array variable, "$facebook_user", as a parameter, but I have no idea why the callback method dose not work at all.
so could some kind bakers tell me the way?
cheers!
In your AppController add or modify your beforeFilter():
function beforeFilter(){
$fbUser = $this->Connect->user();
$Facebook = new FB();
if($fbUser){
$this->set('facebook_user', $fbUser);
$user = $this->Auth->user();
$this->set('user', $user);
if($this->Auth->user('id') && !$user['User']['has_details'] && !$user['User']['email']){
$this->loadModel('User');
$user['User']['username'] = $fbUser['username'];
$user['User']['first_name'] = $fbUser['first_name'];
$user['User']['last_name'] = $fbUser['last_name'];
$user['User']['link'] = $fbUser['link'];
$user['User']['gender'] = $fbUser['gender'];
$user['User']['email'] = $fbUser['email'];
$user['User']['has_details'] = true;
if($this->User->save($user, array('validate' => false))){
$this->Session->write('Auth.User.has_details', true);
}
}
}
}