[Typo3] XCLASS error in module

Joey Dwyer joey at playnames.net
Sun Mar 27 23:54:32 CEST 2005

Joey Dwyer wrote:

> I am working through the Modern Template Building part 2 tutorial. I have
created an extension that allows selection of which template to use on a
page, as well as which sub template (content template) to use. The main page
template selector is working (I've reached page 19 in the PDF file of the
documentation). However, the "sub" template for the content area is not
showing the options in the drop down list, or the icon options.
The best would be to post your code for the Template Autoparser
and the Page Template Selector which you most probably used so we can look
for mistakes (there were some changes in recent versions of Page Template

I have resolved the problem with a workaround by deleting the class
extension that reused the parser for the "sub" section. After I did this, it
started working fine. However, I would still like to know what I did wrong
for future reference. Here is the code from before the fix:

// Include the parse-html class:

class tx_nwstmpl_addfiles {
    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 =
                // Start up the HTML parser:
            $parseHTML = t3lib_div::makeInstance('t3lib_parseHTML');

                // Traverse that array:
            foreach($template_files as $htmlFilePath)    {
                // Reset vars:
                    // 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 =
                    // Setting the item label:
                $selectorBoxItem_title = trim($titleTagContent.'
                    // Trying to look up an image icon for the template
                $fI = t3lib_div::split_fileref($htmlFilePath);
                if (@is_file($testImageFilename))    {    // If an icon was
found, set the icon reference value:
                    $selectorBoxItem_icon =
                    // Finally add the new item:
        // No return - the $params and $pObj variables are passed by
reference, so just change content in them and it is passed back
class tx_nwstmpl_addfiles_ca extends tx_nwstmpl_addfiles {
    var $dir = "sub";

More information about the TYPO3-english mailing list