7 Reaktionen zu “Mit TypoScript am Ende – userFunc hilft”

Kommentare abonnieren (RSS) oder TrackBack URL

Ein schönes Tutorial über userFuncs, vielen Dank

Lina am 15. Juni 2010 um 21:34

Hi Alex,
Danke für die Zusammenstellung!

Hier meine Lösung:

TS:
——————————————-
includeLibs.user_misc = fileadmin/ext/wfqbe/user_misc.php
plugin.tx_wfqbe_pi1.customProcess.34 {
0 = USER
0.userFunc = user_misc->stristrTypoScript
0.userFunc {
# whole string
searchText = TEXT
searchText.data = GPVar:tx_wfqbe_pi1|ID

# keyword to search for
searchFor = X

# TypoScript if keyword found
foundText = TEXT
foundText.value = ###WFQBE_FIELD_0###
foundText.typolink = 1
foundText.typolink.parameter = 85
foundText.typolink.additionalParams = &tx_wfqbe_pi1[TAB]=x
foundText.typolink.additionalParams.stdWrap.dataWrap = |&tx_wfqbe_pi1[COL]=###WFQBE_FIELD_0###&tx_wfqbe_pi1[IDX]={GPVar:tx_wfqbe_pi1|ID}
foundText.typolink.htmlSpecialChars = 1

# TypoScript if keyword not found
notFoundText = TEXT
notFoundText.value = ###WFQBE_FIELD_0###
notFoundText.typolink = 1
notFoundText.typolink.parameter = 85
notFoundText.typolink.additionalParams = &tx_wfqbe_pi1[TAB]=y
notFoundText.typolink.additionalParams.stdWrap.dataWrap = |&tx_wfqbe_pi1[COL]=###WFQBE_FIELD_0###&tx_wfqbe_pi1[IDX]={GPVar:tx_wfqbe_pi1|ID}
notFoundText.typolink.htmlSpecialChars = 1
}
}
——————————————-

PHP:
——————————————-
cObj; // cObject
$conf = $conf['userFunc.']; // ts config
$searchFor = $conf['searchFor']; // get string
$searchText = $local_cObj->cObjGetSingle($conf['searchText'], $conf['searchText.']); // stdWrap for search Text
$foundText = $local_cObj->cObjGetSingle($conf['foundText'], $conf['foundText.']); // stdWrap for found Text
$notFoundText = $local_cObj->cObjGetSingle($conf['notFoundText'], $conf['notFoundText.']); // stdWrap for not found Text
if ( $bDebug )
{
print_r ( “searchText: ” . $searchText . “\n” );
print_r ( “searchFor: ” . $searchFor . “\n” );
}
// let’s go
if (stristr($searchText, $searchFor))
{ // if keyword found
if ( $bDebug )
{
echo (‘keyword found, return: ‘);
print_r ( $foundText );
die ();
}
return $foundText; // return found text
}
else
{ // keyword not found
if ( $bDebug )
{
echo (‘keyword not found, return: ‘);
print_r ( $notFoundText );
die ();
}
return $notFoundText; // return not found
}
}
}
?>
——————————————-

Christoph Lauber am 24. Juni 2010 um 15:54

Danke! Vielleicht stelle ich mich ja komisch an, aber ich habe irgendwie große Schwierigkeiten gehabt, in der Dokumentation einen aussagekräftigen Einstieg zu finden (für Userfunctions).

Thomas am 20. Dezember 2011 um 16:50

In eurem Beispiel 2 – Schritt 3 hat sich wohl ein Fehler eingeschlichen. Denn statt

zahl {
number = TEXT
number.field = number
}

müsste es meiner Meinung nach folgendermaßen lauten (sonst funktioniert der Zugriff in der userfunc nicht):

zahl.userFunc {
number = TEXT
number.field = number
}

Ansonsten war euer Beispiel ein guter Ausgangspunkt!

Jan-Markus Gomer am 15. April 2012 um 17:49

Super Anleitung!!!
vielen vielen Dank :D

Stefan am 26. April 2012 um 01:33
Trackbacks & Pingbacks

[...] Mit TypoScript am Ende – Userfunc hilft: http://typo3blogger.de/mit-typoscript-am-ende-userfunc-hilft/ [...]

Pingback von userFunc Tutorial am 07. März 2011 um 15:50
Ein Kommentar hinterlassen


 Name


 Mail (wird nicht veröffentlicht)


 Website

Bitte beachten sie, dass ihr Kommentar möglicherweise erst freigeschaltet werden muss.

Kategorien

Archiv (Quick)

Mai 2012
M D M D F S S
« Apr    
 123456
78910111213
14151617181920
21222324252627
28293031