This is one of the easiest thing that just helps us do almost anything with TYPO3 content.
Well, yes, still the basic stuff we need to find out is how to get this done.
Generally you might have seem in extensions that they use stdWrap, and consider you wish to process the content after the stdWrap is applied.
ex:
After generating a menu, after a news text is displayed from tt_news etc…
As with all my posts, I just love to keep thngs short, so I will just explain this with relation to a tt_news example:
Step 1: Find out where you can bind your user function:
I was in need of processing the news content to strip some special characters from word, so this is what I did.
I could also have used the plugin.tt_news.general_stdWrap.postUserFunc, I however did not wish to touch each field, as I only needed some selected fields to be affected.
Thus, on looking into tt_news/pi/class.tx_ttnews.php I found that there is a config I can make use of that is “itemMarkerArrayFunc”.
Step 2 : Write your user function.
NOTE 1:
Write your userFunc within standard PHP tags, and save it in fileadmin, or EXT folder.
ex:<?php
//code here
?>NOTE 2:
Makse sure to understand what type of data is available to us, well sometimes it might be an array as in this case.NOTE 3:
Your function name should start with “user_”NOTE 4:
Your function declaration should have enough arguments, if not you might be in a surprise.
Generally if you are using parseFunc of stdWrap your function may look like this:
ex:function user_ProcessData($content,$config){
// do something with $content
$modifiedContent = $content . ” This is modifed”;
return $modifiedContent;}
THE USER FUNCTION
In my case the function looks like thisfunction user_ProcessData($markerArray, $conf) {
$str = $markerArray[‘###NEWS_CONTENT###’];
$str = str_replace(‘###CUSTOMER###’,’Customer Name’,$str);
$markerArray[‘###NEWS_CONTENT###’] = $str ;
return $markerArray;}
Step 3: Include this file in typo3
This can be done in several ways, and here is one such method:
# Add the following code to the setup section of your System Template record. ( we will usually have setup and constants here in General Tab )
includeLibs.itemMarkerArrayFunc = EXT:customext_libs/userNewsMarkerProcessFunc.php
# customext_libs – is the name of an extension
Step 4: Add final config, so that tt_news knows we want to make use of a parseFunc / userFunc
plugin.tt_news.itemMarkerArrayFunc = user_ProcessData
Step 5: This should generally work.
If not please make sure you followed everything as per the above seteps!