diff --git a/inc/common.php b/inc/common.php
index af0123fcd80f5b2a1b3d23541d26e8555c0acdbe..f40c8f1fd3e854984efc10df110da069d7752070 100644
--- a/inc/common.php
+++ b/inc/common.php
@@ -396,6 +396,16 @@ function rawWiki($id,$rev=''){
   return io_readFile(wikiFN($id,$rev));
 }
 
+/**
+ * Returns the pagetemplate contents for the ID's namespace
+ *
+ * @author Andreas Gohr <andi@splitbrain.org>
+ */
+function pageTemplate($id){
+  return io_readFile(dirname(wikiFN($id)).'/_template.txt');
+}
+
+
 /**
  * Returns the raw Wiki Text in three slices.
  *
diff --git a/inc/html.php b/inc/html.php
index 8e576bb58bb7950531f03c53302bd81114ba3982..7768a1005f127188973f08986667193d2a714cff 100644
--- a/inc/html.php
+++ b/inc/html.php
@@ -817,6 +817,7 @@ function html_register(){
 /**
  * This displays the edit form (lots of logic included)
  *
+ * @fixme  this is a huge lump of code and should be modularized
  * @author Andreas Gohr <andi@splitbrain.org>
  */
 function html_edit($text=null,$include='edit'){ //FIXME: include needed?
@@ -843,10 +844,15 @@ function html_edit($text=null,$include='edit'){ //FIXME: include needed?
   //no text? Load it!
   if(!isset($text)){
     $pr = false; //no preview mode
-    if($RANGE){
-      list($PRE,$text,$SUF) = rawWikiSlices($RANGE,$ID,$REV);
+    if($INFO['exists']){
+      if($RANGE){
+        list($PRE,$text,$SUF) = rawWikiSlices($RANGE,$ID,$REV);
+      }else{
+        $text = rawWiki($ID,$REV);
+      }
     }else{
-      $text = rawWiki($ID,$REV);
+      //try to load a pagetemplate
+      $text = pageTemplate($ID);
     }
   }else{
     $pr = true; //preview mode