[TYPO3] modern template building 2 - problems
Aleksandar Milovac
aleksandar.milovac at rns-nis.co.yu
Wed Mar 8 08:40:24 CET 2006
Hi everybody,
I've installed typo3 dummy-3.8.1 on my Debian Sarge machine. I'm using
php 4.2 and MySQL 4.1.
I started to read MTB2+3 tutorial in order to figure out how to set
and work with multiple templates. I'm having some troubles at start of
the tutorial. On pages 15 to 17 there are instructions on how to change
files named ext_tables.php and
class.tx_tmplselect_pages_tx_tmplselect_main_tmpl.php in order to get a
selection box for the main and content area templates.
After I've changed these files I can't log into the dummy package
anymore. I've been getting this message:
Parse error: parse error, unexpected T_REQUIRE_ONCE in
/var/www/dummy-3.8.1/typo3conf/ext/tmplselect/class.tx_tmplselect_addfilestosel.php
on line 33
The content of the files is as follows:
class.tx_tmplselect_addfilestosel.php:
<?php
/***************************************************************
* Copyright notice
*
* (c) 2005 Kasper (kasper at typo3.com)
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Class/Function which manipulates the item-array for table/field
pages_tx_tmplselect_main_tmpl.
*
* @author Kasper <kasper at typo3.com>
*/
// 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";
}
if (defined('TYPO3_MODE') &&
$TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/tmplselect/class.tx_tmplselect_addfilestosel.php'])
{
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/tmplselect/class.tx_tmplselect_addfilestosel.phpl.php']);
}
?>
and ext_tables.php:
?php
if (!defined ("TYPO3_MODE")) die ("Access denied.");
if (TYPO3_MODE=="BE") {
include_once(t3lib_extMgm::extPath("tmplselect").
"class.tx_tmplselect_addfilestosel.php");
}
$tempColumns = Array (
"tx_tmplselect_main_tmpl" => Array (
"exclude" => 1,
"label" =>
"LLL:EXT:tmplselect/locallang_db.php:pages.tx_tmplselect_main_tmpl",
"config" => Array (
"type" => "select",
"items" => Array (
Array(
"LLL:EXT:tmplselect/locallang_db.php:pages.tx_tmplselect_main_tmpl.I.0",
"0",
t3lib_extMgm::extRelPath("tmplselect")."selicon_pages_tx_tmplselect_main_tmpl_0.gif"
),
),
"itemsProcFunc" => "tx_tmplselect_addfilestosel->main",
)
),
"tx_tmplselect_ca_tmpl" => Array (
"exclude" => 1,
"label" =>
"LLL:EXT:tmplselect/locallang_db.php:pages.tx_tmplselect_ca_tmpl",
"config" => Array (
"type" => "select",
"items" => Array (
Array(
"LLL:EXT:tmplselect/locallang_db.php:pages.tx_tmplselect_ca_tmpl.I.0",
"0",
t3lib_extMgm::extRelPath("tmplselect")."selicon_pages_tx_tmplselect_ca_tmpl_0.gif"
),
),
"itemsProcFunc" => "tx_tmplselect_addfilestosel_ca->main",
)
),
);
t3lib_div::loadTCA("pages");
t3lib_extMgm::addTCAcolumns("pages",$tempColumns,1);
t3lib_extMgm::addToAllTCAtypes("pages","tx_tmplselect_main_tmpl;;;;1-1-1,
tx_tmplselect_ca_tmpl");
?>
Can anyone help?
Thanks!
More information about the TYPO3-english
mailing list