Umschreiben Von Html Auf Php

C

Colan

Guest
Huhu zusammen, wie schreibe ich das hier um damit es auf meiner Website angezeigt wird? Ich benutze PhP Fusion

Code:
<link rel="stylesheet" type="text/css" href="http://www.buffed.de/snipplet-1.css">
<form action="http://www.buffed.de" method="post" style="margin:0;" target="_blank">
<table border="0" cellpadding="0" cellspacing="0" width="100" height="44" background="http://www.buffed.de/images/snipplet-small-1-background.gif">
<tr>
	<td height="17" colspan="2"><a href="http://www.buffed.de" target="_blank"><img src="http://www.buffed.de/images/snipplet-small-1-blasc-logo.gif" width="100" height="17" border="0"></a></td>
</tr>
<tr>
	<td height="27" width="68" align="center"><input type="text" name="f" value=" Suchen" class="small-snipplet1-input" onfocus="if(this.value==' Suchen') this.value=''"></td>
	<td height="27" width="34"><input type="image" src="http://www.buffed.de/images/snipplet-small-1-input-ok.gif"></td>
</tr>
</table>
</form>

Wäre echt dankbar wenn mir jemand helfen könnte

Gruß Colan
 
Variante 1 - (zwar absoluter Müll, unsauber, unschön - für Anfänger)
Code:
echo '
<link rel="stylesheet" type="text/css" href="http://www.buffed.de/snipplet-1.css">
<form action="http://www.buffed.de" method="post" style="margin:0;" target="_blank">
<table border="0" cellpadding="0" cellspacing="0" width="100" height="44" background="http://www.buffed.de/images/snipplet-small-1-background.gif">
<tr>
	<td height="17" colspan="2"><a href="http://www.buffed.de" target="_blank"><img src="http://www.buffed.de/images/snipplet-small-1-blasc-logo.gif" width="100" height="17" border="0"></a></td>
</tr>
<tr>
	<td height="27" width="68" align="center"><input type="text" name="f" value=" Suchen" class="small-snipplet1-input" onfocus="if(this.value==\' Suchen\') this.value=''"></td>
	<td height="27" width="34"><input type="image" src="http://www.buffed.de/images/snipplet-small-1-input-ok.gif"></td>
</tr>
</table>
</form>';

Variante 2 - Auslagern + Includen (auch Müll)
Den HTML Code in einer Datei ablegen; Bsp.: blasc_form.html
Code:
include ("blasc_form.html");

Variante 3 - Templates - (schön, sauber, übersichtlich)
Deine komplette Seite auf Templates aufbauen.
Zuvor deinen HTML Code auslagern wie in Variante 2.
Du benötigst die Klasse zamtpl.class.php.
Code:
require ("zamtpl.class.php");
$blasc = new Template('blasc_form.html');

// Das Object $blasc->Out(); enthält jetzt den Code des Formulars und kann weiter verwendet werden
// zb.: durch ein direktes echo $blasc->Out();



Klasse: zamtpl.class.php
Code:
<?
################################################################################
#																			  #
# zamTpl TEMPLATE CLASS v0.4a is Copyright (c)							   #
# Written and developed by Christian Zamora 2003-2004.						 #
#																			  #
# This class 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.														   #
#																			  #
# This program 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.															#
#																			  #
# edited by Ch. Zamora.														#
#																			  #
# Edit Log:																	#
# - dynamic template extension on template assign							  #
# - dynamic template directory choose on template assign					   #
#																			  #
# Note:																		#
# Create an xxxxx.php file and initiate this class like this:				  #
#																			  #
# include ('<classfilename>');												 #
#																			  #
# To initiate an HTML file do following:									   #
# $tpl = new Template('<templatefile>',['<templatedir>',['template extension']]);#
#																			  #
# Optional values are set to templates/ as directory and .tpl as default	   #
# Extension																	#
#																			  #
# To replace content use {NAME} Tags in the HTML file						  #
# e.g.:																		#
#	  If the template file is in the same directory like the scriptfile.	  #
#																			  #
#	  Filename: mytemplate.html											   #
#	  Your Template File source: <html>{TEXT}</html>						  #
#	  The way to replace it:												  #
#	  $tpl = new template('mytemplate','','.html');						   #
#	  $tpl->Add('TEXT', 'Hello World');									   #
#	  echo $tpl->Out();													   #
#	  This will print "Hello World" on your website.						  #
#																			  #
#																			  #
################################################################################
class Template
{
	  var $template = '';
	  var $fields   = Array();

	  /* initiate template
	  * @param filename name of the template file
	  * @param tpldir name of the directory where the templates are stored
	  *				  default is templates/
	  * @param tplext extension of the template files, default is *.tpl
	  */
	  function Template($filename, $tpldir = 'templates/', $tplext = '.tpl')
	  {
			   /* check if template file exists */
			   if (!file_exists($tpldir . $filename . $tplext)) {
				   $this->template = "Fehler: Template '$filename' "
									."existiert leider nicht!\n";
			   }
			   /* if template file exists , put line breaks
				* on every line in the html source
			   */
			   else {
				   $this->template = implode('', file($tpldir . $filename . $tplext));
			   }
	  }
	  /* save content to replace
	  *  @param name
	  *  @param value
	  */
	  function Add($name, $value) {
			   $this->fields[$name] = $value;
	  }
	  /* replace html source and print it */
	  function Out()
	  {
			   while( list($name, $value) = each($this->fields)) {
				$this->template = str_replace('{'.$name.'}', $value, $this->template);
			   }
			   return $this->template;
	  }
}
?>
 
Zurück