😃
Hallo ich greife hier noch mal das Thema auf, da ich das gleiche Problem habe.
Ich habe auch ca. 300 Seiten die ich gerne nach typo 3 importiert hätte...
Wenn ich Dich richtig verstehe, dann sollten vorher die Seiten angelegt werden,
inkl. Ordnerstruktur etc..?
Beim Copy und Paste, ist es da sinnvoller die Dateien als reines Html vorliegen zu haben? Ich habe derzeit meine mit separatem css. Da wird es dann wahrscheinlich schon etwas schwieriger, oder?
Beschreib mir doch bitte kurz mal wie Du das gemacht hast.
Habe im Netz auch folgendes Php-script gefunden, das die html dateien in typo3 importiert.
Weis nur nicht genau wie ich es in Typo3 importieren soll, da es ja keine tx3 Datei ist...
Bitte um Tips
Danke o.O
<?php
/*
READ FIRST!
Typo3 4.0 Import Script for static html files.
this scrip is not directly related to typo3
i have written it for my own needs it may not work for you our our situation!
before you begin BACKUP Your database.
use this scrip at OWN Risk!
you can use & modyfiy this script under the terms of The GNU General Public License
http://www.gnu.org
http://www.gnu.org/licenses/licenses.html#GPL
Author of this scrip: "christian Wolff" <chris@connye.com>
WHAT Does it do?
basicly this script imports a folder structure of html files. into typo3
this script is able of inserting translated content based on a "alternate folder structure
known "bugs"
this script "takes" every file in the folder structure as "html"
basicly this script asumes that the files a stored in a folder tree representing
the tree struckture of the new typo3 tree builde.
i hope this script is usefull for anybody but me
*/
$parentID=1; // the page id of the page where the new importet tree resists
$startDir="F:\Daten\- Projekte\Guenni\pantanal-2005-10-10\web-content\pantanal\de"; // directory where the parising begins.
$indexfile='index.htm'; // the filename of your index.
/*
these strings seperates the content of the "old" static html used to crop out only the neded part
*/
$content_start='<!-- #BeginEditable "Hauptbereich" -->'; // after this your content starts
$content_end='<!-- #EndEditable -->'; // before this your contents end.
$le ="\n"; // line ending for html output just used in the debugging output this script echos in the browser
$psep='\\'; // seperator for files / dirs use backslash ("\\") on windows or slash "/" on *nix operating systems
/* database config - enter your database settings below*/
$db_user='';
$db_password='';
$db_server='localhost';
$db_database='';
/*File for Redirects */
$redir_log_file='redir_log.txt';
/* Here starts the real script */
$db_link=mysql_connect($db_server,$db_user,$db_password);
if(!$db_link){
die('Datenbankverbindung fehlgeschlagen:' . mysql_error());
}
$redir_logfile=fopen($redir_log_file,'w');
/*
simple funkction to querry the db, end get error info if somtthin happens..
*/
function db_querry($SQL){
/*
global $db_link;
global $db_database;
mysql_db_query($db_database,$SQL,$db_link);
$err=mysql_error();
if($err != ''){
echo '<p class="error">SQL Error: '. mysql_error() .'</p><p>SQL Abfrage: '.$SQL.'<p>';
}
*/
}
/*
This function walks down the foldertree and is the base of this scrip
*/
function parse_folders($path,$title,$parentID){ // recursive function to walk the folders
echo "<p>ParentID: $parentID</p>";
global $le;
global $psep;
global $indexfile;
echo '<h1>'. $title . '</h1>'.$le;
echo '<div>'. $le;
$files=array();
$dirs=array();
if (is_dir($path) and is_readable($path)){
$fid =opendir($path);
while (false !== ($file = readdir($fid))) {
if (is_file($path . $psep . $file) and $file!='index.htm'){
$files[] = $file;
}
if(is_dir($path . $psep . $file) and substr($file,0,1)!='.' ){
$dirs[] = $file;
}
}
// Processing folders
foreach($dirs as $i){ // ordner recursiv durcharbeiten
$currentID=build_page_content($parentID,
$path .$psep. $i .$psep. $indexfile,
$i );
echo "<p>CurrentID: $currentID</p>";
parse_folders($path .$psep. $i,
$i,
$currentID);
}
// Processing files
foreach($files as $i){ // Seiten Für die html Dokumente erstellen
build_page_content($parentID,
$path .$psep. $i,
$i);
}
}
echo '</div>'.$le;
}
/*
this function building the content based on given file name an $parent id.
*/
function build_page_content($parentID,$filename,$title){ // function for buliding a page out of a file
/* Building real url segment uses for segment and page title*/
global $indexfile;
global $db_link;
global $content_start;
global $content_end;
global $redir_logfile;
/* Getting Real Url path segment */
if(basename($filename)==$indexfile){
$real_urlsegment=$title;
}else{
$real_urlsegment=basename($filename);
}
echo "$real_urlsegment ";
/*
table: pages
fields:
uid = (auto) soll als $currentID zurück gegeben werden
pid = $parentID
title = path segment
tx_realurl_pathsegment = path segment
first insert the page in the page table
*/
$SQL = "INSERT INTO pages SET
pid = '$parentID',
title = '$real_urlsegment',
tx_realurl_pathsegment='$real_urlsegment'
;
";
db_querry($SQL);
$currendID = mysql_insert_id($db_link);
/*
table: tt_content
fields:
pid = $currentID
CType = html
bodytext = extractet text from file
l18n_parent = 0 Deutsch 1 = Englisch
*/
/* reading content of the file and extract the nessasary */
if (is_file($filename) and is_readable($filename)){
$content=get_content_from_file($filename,$content_start,$content_end);
$content=mysql_real_escape_string($content,$db_link);
/* insert the file content */
$SQL = "INSERT INTO tt_content SET
pid = '$currendID',
CType ='html',
bodytext = '$content',
sys_language_uid = '0',
l18n_parent = '0'
";
db_querry($SQL);
/*
Inserting Redirect Entry to log
*/
fwrite($redir_logfile, ':::pATH:::'. $filename .':::ID:::'. $currendID .'&L=0:::END:::'. "\n");
/*
Checking for translated version of the file
*/
$transfile=str_replace('pantanal\\de\\','pantanal\\en\\',$filename);
if (is_file($transfile) and is_readable($transfile)){
/*
table: pages_language_overlay
fields:
pid = $currentID
sys_language_uid = 1
title = $title
*/
/* insert language overlay for that page */
$SQL = "INSERT INTO pages_language_overlay SET
pid = '$currendID',
sys_language_uid ='1',
title = '$title'
";
db_querry($SQL);
/* insert the content of the translatet file */
$content=get_content_from_file($transfile,$content_start,$content_end);
$content=mysql_real_escape_string($content,$db_link);
$SQL = "INSERT INTO tt_content SET
pid = '$currendID',
CType ='html',
bodytext = '$content',
sys_language_uid ='1',
l18n_parent = '1'
";
db_querry($SQL);
/*
Inserting Redirect Entry to log
*/
fwrite($redir_logfile, ':::pATH:::'. $transfile .':::ID:::'. $currendID .'&L=1:::END:::'. "\n");
}
}else{
echo '<p class="error">Keine übersetzung vorhanden: '.$filename.'<br>'.$transfile.'</p>';
}
return $currendID;
}
/* this function extracts only the nessesary content of a file
here you can add some special operations to transfor content in the way you need
*/
function get_content_from_file($filename,$startag,$endtag){
$content='';
/*$fp=fopen($filename,'r');*/
$content = file_get_contents($filename);
$start=strpos($content,$startag);
$end=strpos($content,$endtag);
$content=substr($content,
$start+strlen($startag),
$end-strlen($startag)-$start
);
/* Correcting image Path and such things */
// <img src="../_pics/indexseite/Pantanal-1.jpg"
// the prefix to make all image references absolut
$prefix='/pantanal/pantanal';
$match=array();
$replace=array();
// two regEx to insert the image prefix corretly
$match[] ='<img([^>]+)src="[\./]*(/_pics/.*)"';
$replace[] ='<img\\1src="'.$prefix .'\\2"';
// making tags xhtml conform just for a better feeling
/*
$match[] ='<img(.*)[^/<]>';
$replace[] ='<img\\1 />';
$match[] ='<embed(.*)[^/<]>';
$replace[] ='<embed\\1 />';
$match[] ='<br(.*)[^/<]>';
$replace[] ='<br\\1 />';
*/
/* for later use...
$match[] ='';
$replace[] ='';
*/
// do All the regEx Things
for ($i=0;$i<count($match);$i++){
while(ereg($match,$content)){
$content=ereg_replace($match,$replace,$content);
}
}
/*
Ugly Markeup fix to get the old "look & feel for old content on the new css based site
basicly overflow the margin correctly if a single image is lager then the margin. to do so
we wrap the old content in a table
*/
$content='<table border="0" cellspacing="0" cellpadding="0"><tr><td></td>'.$content .'</tr></table>';
return $content;
}
/* after all that functions here the start of the process */
?>
<html>
<head><title>parsing for typo3</title></head>
<style>
div {margin-left:10px; padding-left:15px;border-left:3px #ccc solid;}
h1 {margin:10px; border:1px solid #000; padding:4px; font: 12px normal}
.error{color:#900; display:block;clear:both;}
</style>
<body>
<?php
ob_end_flush(); // flush the buffer to generate output while working...
parse_folders($startDir,$startDir,$parentID); // simply start the process of parsing.
?>
</body>
</html>