[TYPO3-english] codes display on my typo3 backend

tom liu tomliutest at gmail.com
Tue May 17 10:46:22 CEST 2011


on my typo3 backend, it displays the below code:(I am reading
MTB_2(3)[modern template building].pdf, after i changed the codes according
to the page 18,this happened)


// Include the parse-html class:
require_once(PATH_t3lib.'class.t3lib_parsehtml.php'); class
tx_tmplselect_addfilestosel { var $dir = "main"; /** * Manipulating the
input array, $params, adding new selectorbox items. */ function
main(&$params,&$pObj) { // configuration of paths for template files:
$confArray = array( "main" => "fileadmin/template/main/", "sub" =>
"fileadmin/template/sub/" ); // Finding value for the path containing the
template files. $readPath =
t3lib_div::getFileAbsFileName($confArray[$this->dir]); // If that directory
is valid, is a directory then select files in it: if (@is_dir($readPath)) {
// Getting all HTML files in the directory: $template_files =
t3lib_div::getFilesInDir($readPath,'html,htm',1,1); // Start up the HTML
parser: $parseHTML = t3lib_div::makeInstance('t3lib_parseHTML'); // Traverse
that array: foreach($template_files as $htmlFilePath) { // Reset vars:
$selectorBoxItem_title=''; $selectorBoxItem_icon=''; // Reading the content
of the template document... $content = t3lib_div::getUrl($htmlFilePath); //
... and extracting the content of the title-tags: $parts =
$parseHTML->splitIntoBlock('title',$content); $titleTagContent =
$parseHTML->removeFirstAndLastTag($parts[1]); // Setting the item label:
$selectorBoxItem_title = trim($titleTagContent.'
('.basename($htmlFilePath).')'); // Trying to look up an image icon for the
template $fI = t3lib_div::split_fileref($htmlFilePath);
$testImageFilename=$readPath.$fI['filebody'].'.gif'; if
(@is_file($testImageFilename)) { // If an icon was found, set the icon
reference value: $selectorBoxItem_icon =
'../'.substr($testImageFilename,strlen(PATH_site )); } // Finally add the
new item: $params["items"][]=Array( $selectorBoxItem_title,
basename($htmlFilePath), $selectorBoxItem_icon ); } } // No return - the
$params and $pObj variables are passed by reference, so just change content
in them and it is passed back automatically... } } class
tx_tmplselect_addfilestosel_ca extends tx_tmplselect_addfilestosel { var
$dir = "sub"; }


More information about the TYPO3-english mailing list