Typo3 Typoscript additionalHeaders header location using variable - typo3

I try to redirect a link which is coming, but before part of the link should be replaced.
tmp.getSlug = TEXT
tmp.getSlug.data = getIndpEnv : TYPO3_REQUEST_URL
tmp.getSlug.replacement {
10 {
search = myLinkPart
replace = myNewLinkPart
}
}
config.additionalHeaders.10 {
header = Location: {tmp.getSlug}
}
So from: www.myUrl.de/test/myLinkPart/test2/
To: www.myUrl.de/test/myNewLinkPart/test2/
It must be inside Typoscript because of other conditions.
Does anybody has an idea?

you are mixing different objects in a non functional way.
First you define tmp.getSlug as a typoscript object. Then you try to use it as a data variable.
Additional everything beyond tmp. is not available at rendering time. (it just is available when the typoscript is scanned.)
If you want to use the evaluation of tmp.getSlug you need to assign it to a permanent object and then store it in a register so you can access it afterwards.
Additional you need a flexible object to compose the Location header, which by default just contains a string.
Either a text object where you can use data (which must be evaluated and stored in a register before) or a COA to compose the static and the dynamic string.
This might be a solution:
tmp.getSlug = TEXT
tmp.getSlug.data = getIndpEnv : TYPO3_REQUEST_URL
tmp.getSlug.replacement {
10 {
search = myLinkPart
replace = myNewLinkPart
}
}
config.additionalHeaders.10 {
header.cObject = COA
header.cObject {
10 = TEXT
10.value = Location:
20 < tmp.getSlug
}
}

Related

Typo3 Powermail form - Send Page UID to receiver

I've created a small application form for my website. Everything works fine.
In the plugin settings there is a field called "Bodytext for Email to Receiver". This is the the mail I get, everytime somebody fills out an application form. It looks like this right now:
New application arrived!
{powermail_all}
Is it possible to get the Page UID from the application form into a variable to put it in there?
The only solutions I've found need TypoScript. Is there any other way?
The solution with typoscript should be (according to manual):
use in template:
{f:cObject(typoscriptObjectPath:'lib.pageuid')}
define the typoscript:
lib.pageuid = TEXT
lib.pageuid.data = page:uid
I'm not sure about an additional variable for {powermail_all} as I'm not familiar with the extension.
If I understand the manual correctly this might be possible with :
plugin.tx_powermail {
settings {
setup {
manipulateVariablesInPowermailAllMarker {
// possible sections (define for each, where you need it):
// confirmationPage, submitPage, receiverMail, senderMail, optinMail
submitPage {
pageUid = TEXT
pageUid.data = page:uid
}
senderMail {
pageUid = TEXT
pageUid.data = page:uid
}
}
}
}
}

Add formhandler field data to subject

My goal is to have the Formhandler log UID inside the Admin emails subject.
Inside of my email template I'm using
###value_tx_formhandler_log_inserted_uid### to insert a unique id.
I need to get this value into my Admin emails subject. E.g.
"Order ID: ###value_tx_formhandler_log_inserted_uid###"
I've read various forum posts, each do something different and I ended up with this snippet:
plugin.Tx_Formhandler.settings.predef.form {
# TEMPLATE MARKERS
name = Form1
templateFile = typo3template/typo3/ext/formhandler/form1/default.html
markers {
name = TEXT
name.value = Form1
}
finishers {
1.config {
class = Tx_Formhandler_Finisher_Mail
subject = TEXT
subject.value = ###GP:tx_formhandler_log_inserted_uid###
}
}
[...]
which just yields "{$formhandler.admin.subject}" as the subject.
I also tried other variations like
###LLL:tx_formhandler_log_inserted_uid### or tx_formhandler_log_inserted_uid
The backend field "subject" is empty.
Pasting the HTML placeholder into the backend field didn't work either.
I can't get this to work.
In what way can you access the id you want to insert?
From the notation GP:tx_formhandler_log_inserted_uid I would assume a GET/POST value.
For using this value in typoscript you need to do it like this (or similar: dataWrap):
subject = TEXT
subject.data = GP:tx_formhandler_log_inserted_uid
subject.noTrimWrap = |Order ID: ||
The notation LLL:tx_formhandler_log_inserted_uid would be a language specific text (you would also insert by .data) but it would be a static text for each language.
After a lot of trial and error, I got it working.
First of all, I forgot to specify that I want to configure the admin mail.
Adding admin { fixed the problem of getting only {$formhandler.admin.subject}.
The UID value itself can be accessed with GP:formhandler|tx_formhandler_log_inserted_uid
I combined that with the noTrimWrap as suggested by #bernd-wilke-πφ
The final snippet looks like this:
finishers {
1 {
class = Tx_Formhandler_Finisher_Mail
config {
admin {
subject = TEXT
subject.data = GP:formhandler|tx_formhandler_log_inserted_uid
subject.noTrimWrap = |Order number: ||
}
}
}
}

TYPO3/Typoscript : trim value failed

This is my typoscript code :
lib.test.renderObj = COA
lib.test.renderObj.10 = TEXT
lib.test.renderObj.10.stdWrap.field = header
lib.test.renderObj.10.stdWrap.case = lower
lib.test.renderObj.10.stdWrap.trim = 1
lib.test.renderObj.10.stdWrap.wrap = <div class="element">|</div>
The header field is well received, letters have been lowercased and the field is well wrapped by a element. The only problem is that i can't make the TRIM properties effective. I also tried to use the search/replace properties -> no success.
Any clue ? :)
You can search and replace since 4.6. The documentation you can find here: https://docs.typo3.org/typo3cms/TyposcriptReference/6.2/Functions/Replacement/
lib.test.renderObj.10.stdWrap.replacement {
10 {
search = # #
replace =
useRegExp = 1
}
}
Don't know if the replace is really working, can't test it.

TYPO3: Special tt_contenttype. Modify content before output

Can I create a "special" type of tt_content, so text is beeing processed in some custom ways before outputtet?
In my case I would like to add ###MY_MARKER### somewhere in header and/or bodytext and have it replaced by the right words for the given page.
eg:
When visiting this page: mypage.com/?marker=test
Header in tt_content: "Welcome to ###MY_MARKER##, enjoy
Output in browser: "Welcome to TEST, enjoy"
I CAN do it by making a custom plugin. Question is more if I can reuse normal tt_contant for the same purpose
Yes, you can easily extend the tt_content by adding your own TCA configuration to the typo3conf/extTables.php file:
t3lib_div::loadTCA('tt_content');
$TCA['tt_content']['columns']['CType']['config']['items']['user_my_type'] = array(
0 => 'My custom content',
1 => 'user_my_type',
2 => 'i/tt_content.gif',
);
$TCA['tt_content']['ctrl']['typeicon_classes']['user_my_type'] = 'mimetypes-x-content-text';
$TCA['tt_content']['ctrl']['typeicons']['user_my_type'] = 'tt_content.gif';
/* In the following either copy, insert and modify configuration from some other
content elemenet (you can find it in the ADMIN TOOLS -> Configuration - $TCA)... */
$TCA['tt_content']['types']['user_my_type']['showitem'] = '';
/* ...or assign it some other configuration so that it's exactly the same
as some other content type and stays the same after some update of TYPO3: */
$TCA['tt_content']['types']['user_my_type']['showitem'] = $TCA['tt_content']['types']['text']['showitem'];
After that, just set in your Typoscript template how the element is supposed to be rendered:
tt_content.user_my_type = COA
tt_content.user_my_type {
10 = TEMPLATE
10 {
template = TEXT
template.field = header
marks {
MY_MARKER = TEXT
MY_MARKER.value = TEST
}
}
20 = TEMPLATE
20 {
template = TEXT
template {
field = bodytext
required = 1
parseFunc = < lib.parseFunc_RTE
}
marks < tt_content.user_my_type.10.marks
}
}
NOTES
The Typoscript rendering is just a simplified example. You might want to add other standard configuration like in other elements, e.g. the one that adds edit icons for frontend display.
The marker in my example can be populated by the value of a GET paramater in the URL as you wanted but this would have nasty security implications. You would certainly need very good validation of that input.

TYPO3: Parse current url into variable

i know how i get the current URL with typoscript, but i dont know how i can parse this url into a variable so i can use and work with it.
temp.getUrl = TEXT
temp.getUrl.typolink {
parameter.data=TSFE:id
returnLast=url
}
This example returns me an url segment like 'This/is/just/a/test.html', so long – perfect!
Now i try to save this url into an Variable like
temp.getUrl = TEXT
temp.getUrl.typolink {
parameter.data=TSFE:id
returnLast=url
}
wiredMindsCompleteUrl < temp.getUrl
This results everytime just with 'TEXT' :( i kinda depressed.
Please help :)
The question is, where do you want to use it.
If you want to use it in different places in TypoScript you can f.e. render it into stdWrap.append / stdWrap.prepend of your links.
myMenu = HMENU
myMenu ...
myMenu.stdWrap.append < temp.getUrl
You could just put it into an Register:
page.1.LOAD_REGISTER
page.1.getUrl < temp.getUrl
and f.e. use your register in the tilte-Tag of an image:
lib.MyImage = IMAGE
lib.MyImage.file = ...
lib.MyImage.titleText.data = REGISTER:getUrl
lib.MyImage.tilteText.noTrimWrap = | makes no sense (IMHO:) ||
If you need it in your extension, just use it with cObjGetSingle.
plugin.tx_yourextension_pi1.getUrl < temp.getUrl
Inside your extension use it via
function main($content, $conf) {
$this->conf = $conf;
return $this->cObj->cObjGetSingle($this->conf['getUrl'], $this->conf['getUrl.'], 'getUrl');
}
Side note: use lib.getUrl instead of temp.getUrl, otherwise you can get in trouble with non-cached TypoScript parts.