Index: /trunk/blocks/recent_comments_block.php
===================================================================
--- /trunk/blocks/recent_comments_block.php	(revision 88)
+++ /trunk/blocks/recent_comments_block.php	(revision 89)
@@ -21,5 +21,5 @@
 		$disp_length = empty( $options[2] ) ? '30' : $options[2] ;
 	    $selected = array_slice($options,3); // get allowed cats
-		$this_template = empty( $options[4] ) ? 'db:'.$mydirname.'_block_comments.html' : trim( $options[4] );
+		$this_template = empty( $options[4] ) ? 'db:'.$mydirname.'_block_recent_comments.html' : trim( $options[4] );
 		$mydirpath = XOOPS_ROOT_PATH . '/modules/' . $mydirname;
 
Index: /trunk/blocks/recent_posts_content_block.php
===================================================================
--- /trunk/blocks/recent_posts_content_block.php	(revision 88)
+++ /trunk/blocks/recent_posts_content_block.php	(revision 89)
@@ -23,5 +23,5 @@
 		$tag_select = $options[4] ;
 	    $selected = array_slice($options,5); // get allowed cats
-		$this_template = empty( $options[6] ) ? 'db:'.$mydirname.'_block_content.html' : trim( $options[5] );
+		$this_template = empty( $options[6] ) ? 'db:'.$mydirname.'_block_recent_posts_content.html' : trim( $options[5] );
 
 		$mydirpath = XOOPS_ROOT_PATH . '/modules/' . $mydirname;
Index: /trunk/include/oninstall.php
===================================================================
--- /trunk/include/oninstall.php	(revision 88)
+++ /trunk/include/oninstall.php	(revision 89)
@@ -87,5 +87,5 @@
 //   	require_once($mydirpath . '/include/user_sync.php');
 	$sync_messg = '';
-	xpress_user_sync($ID,$sync_messg);		//this function in XPressME plugin 
+//	user_sync_to_wordpress($ID,$sync_messg);		//this function in XPressME plugin 
 
 	// Set Default data
@@ -138,7 +138,45 @@
 	$sql = "INSERT INTO $group_role (groupid, role) VALUES (1, 'administrator')";
 	$wpdb->query($sql);
-	// make templates
-//	include_once XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/include/xpress_templates.php' ;
-//	$ret = xpress_install_templates($mid,$mydirname);
+	
+	// TEMPLATES
+	$tplfile_handler =& xoops_gethandler( 'tplfile' ) ;
+	$tpl_path = dirname( dirname( __FILE__ ) ).'/templates/source' ;
+	if( $handler = @opendir( $tpl_path . '/' ) ) {
+		while( ( $file = readdir( $handler ) ) !== false ) {
+			if( substr( $file , 0 , 1 ) == '.' ) continue ;
+			$file_path = $tpl_path . '/' . $file ;
+			if( is_file( $file_path ) ) {
+				$mtime = intval( @filemtime( $file_path ) ) ;
+				$tplfile =& $tplfile_handler->create() ;
+				$tplfile->setVar( 'tpl_source' , file_get_contents( $file_path ) , true ) ;
+				$tplfile->setVar( 'tpl_refid' , $mid ) ;
+				$tplfile->setVar( 'tpl_tplset' , 'default' ) ;
+				$tplfile->setVar( 'tpl_file' , $mydirname . '_' . $file ) ;
+				$tplfile->setVar( 'tpl_desc' , '' , true ) ;
+				$tplfile->setVar( 'tpl_module' , $mydirname ) ;
+				$tplfile->setVar( 'tpl_lastmodified' , $mtime ) ;
+				$tplfile->setVar( 'tpl_lastimported' , 0 ) ;
+				$tplfile->setVar( 'tpl_type' , 'block' ) ;
+				if( ! $tplfile_handler->insert( $tplfile ) ) {
+					$ret[] = '<span style="color:#ff0000;">ERROR: Could not insert template <b>'.htmlspecialchars($mydirname.'_'.$file).'</b> to the database.</span><br />';
+				} else {
+					$tplid = $tplfile->getVar( 'tpl_id' ) ;
+					$ret[] = 'Template <b>'.htmlspecialchars($mydirname.'_'.$file).'</b> added to the database. (ID: <b>'.$tplid.'</b>)<br />';
+					// generate compiled file
+					include_once XOOPS_ROOT_PATH.'/class/xoopsblock.php' ;
+					include_once XOOPS_ROOT_PATH.'/class/template.php' ;
+					if( ! xoops_template_touch( $tplid ) ) {
+						$ret[] = '<span style="color:#ff0000;">ERROR: Failed compiling template <b>'.htmlspecialchars($mydirname.'_'.$file).'</b>.</span><br />';
+					} else {
+						$ret[] = 'Template <b>'.htmlspecialchars($mydirname.'_'.$file).'</b> compiled.</span><br />';
+					}
+				}
+			}
+		}
+		closedir( $handler ) ;
+	}
+	include_once XOOPS_ROOT_PATH.'/class/xoopsblock.php' ;
+	include_once XOOPS_ROOT_PATH.'/class/template.php' ;
+	xoops_template_clear_module_cache( $mid ) ;
 
 	return true ;
Index: /trunk/include/onupdate.php
===================================================================
--- /trunk/include/onupdate.php	(revision 88)
+++ /trunk/include/onupdate.php	(revision 89)
@@ -132,9 +132,46 @@
 	}
 	
-	clean_template($mydirname,$xpress_version);
-
-	// update templates
-//	include_once XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/include/xpress_templates.php' ;
-//	$msgs = xpress_update_templates($mid,$mydirname);
+	// TEMPLATES (all templates have been already removed by modulesadmin)
+
+	$tplfile_handler =& xoops_gethandler( 'tplfile' ) ;
+	$tpl_path = dirname( dirname( __FILE__ ) ).'/templates/source' ;
+	if( $handler = @opendir( $tpl_path . '/' ) ) {
+		while( ( $file = readdir( $handler ) ) !== false ) {
+			if( substr( $file , 0 , 1 ) == '.' ) continue ;
+			$file_path = $tpl_path . '/' . $file ;
+			if( is_file( $file_path ) ) {
+				$mtime = intval( @filemtime( $file_path ) ) ;
+				$tplfile =& $tplfile_handler->create() ;
+				$tplfile->setVar( 'tpl_source' , file_get_contents( $file_path ) , true ) ;
+				$tplfile->setVar( 'tpl_refid' , $mid ) ;
+				$tplfile->setVar( 'tpl_tplset' , 'default' ) ;
+				$tplfile->setVar( 'tpl_file' , $mydirname . '_' . $file ) ;
+				$tplfile->setVar( 'tpl_desc' , '' , true ) ;
+				$tplfile->setVar( 'tpl_module' , $mydirname ) ;
+				$tplfile->setVar( 'tpl_lastmodified' , $mtime ) ;
+				$tplfile->setVar( 'tpl_lastimported' , 0 ) ;
+				$tplfile->setVar( 'tpl_type' , 'block' ) ;
+				if( ! $tplfile_handler->insert( $tplfile ) ) {
+					$msgs[] = '<span style="color:#flockf0000;">ERROR: Could not insert template <b>'.htmlspecialchars($mydirname.'_'.$file).'</b> to the database.</span>';
+				} else {
+					$tplid = $tplfile->getVar( 'tpl_id' ) ;
+					$msgs[] = 'Template <b>'.htmlspecialchars($mydirname.'_'.$file).'</b> added to the database. (ID: <b>'.$tplid.'</b>)';
+					// generate compiled file
+					include_once XOOPS_ROOT_PATH.'/class/xoopsblock.php' ;
+					include_once XOOPS_ROOT_PATH.'/class/template.php' ;
+					if( ! xoops_template_touch( $tplid ) ) {
+						$msgs[] = '<span style="color:#ff0000;">ERROR: Failed compiling template <b>'.htmlspecialchars($mydirname.'_'.$file).'</b>.</span>';
+					} else {
+						$msgs[] = 'Template <b>'.htmlspecialchars($mydirname.'_'.$file).'</b> compiled.</span>';
+					}
+				}
+			}
+		}
+		closedir( $handler ) ;
+	}
+	include_once XOOPS_ROOT_PATH.'/class/xoopsblock.php' ;
+	include_once XOOPS_ROOT_PATH.'/class/template.php' ;
+	xoops_template_clear_module_cache( $mid ) ;
+
 	
 	return true ;
@@ -176,47 +213,4 @@
 endif;
 
-if( ! function_exists( 'clean_template' ) ) :
-function clean_template($mydirname,$xpress_ver){
-		global $xoopsModule;
-		
-		$var = floatval($xpress_ver);
-		switch ($var){
-			case ($var >= 0.62):
-				$temp_file = "'". $mydirname . "_home.html','" . $mydirname. "_index.html','" . $mydirname . "_search.html','" . $mydirname . "_single.html'";
-				break;
-			case ($var >= 0.60):
-				$temp_file = "'xpress_header.html','xpress_home.html','xpress_index.html','xpress_search.html','xpress_sidebar.html'";
-				break;
-			default:
-				$temp_file = 'all';
-		}
-		
-		if ($temp_file != 'all'){			
-			$xoopsDB =& Database::getInstance();
-			$db_tplfile = $xoopsDB->prefix('tplfile');
-			$db_tplsource = $xoopsDB->prefix('tplsource');
-
-			$sql = "SELECT * FROM $db_tplfile WHERE tpl_module = '$mydirname' AND NOT tpl_file IN($temp_file)";
-			$res = $xoopsDB->query($sql, 0, 0);
-			if ($res === false){
-				return false;
-			} else {
-				$del_array = '';
-				$i=0;
-				while($row = $xoopsDB->fetchArray($res)){
-					if (!empty($del_array))
-					$del_array .= ',';
-					$del_array .= $row['tpl_id'];
-				}
-				if(!empty($del_array)){
-					$del_tplfile  = "DELETE FROM $db_tplfile WHERE tpl_id IN ($del_array)";
-					$result = $xoopsDB->query($del_tplfile, 0, 0);
-					$del_tplsource  = "DELETE FROM $del_tplsource WHERE tpl_id IN ($del_array)";
-					$result = $xoopsDB->query($del_tplfile, 0, 0);
-				}
-			}
-		}
-}
-endif;
 
 if( ! function_exists( 'enhanced_table_check' ) ) :
Index: /trunk/include/xpress_block_render.php
===================================================================
--- /trunk/include/xpress_block_render.php	(revision 88)
+++ /trunk/include/xpress_block_render.php	(revision 89)
@@ -104,6 +104,6 @@
 		$inc_theme_file_name = $call_theme_function_name . '_theme.php';
 		$cache_title = str_replace(".php", "", $block_function_name);
-		$blockID =get_block_id($mydirname,$func_file,$options);			
-					
+		$blockID =get_block_id($mydirname,$func_file,$options);		
+
 		if (!is_null($wpdb)){
 			xpress_block_css_set($mydirname);
@@ -119,5 +119,10 @@
 			$block = $xml['block'];
 		}
-		return 	$block;
+
+		$templates_file = 'db:'.$mydirname. '_' . str_replace(".php", ".html", $block_function_name);
+		$tpl =& new XoopsTpl() ;
+		$tpl->assign( 'block' , $block ) ;
+		$ret['content'] = $tpl->fetch( $templates_file ) ;
+		return $ret ;
 	}
 	
Index: /trunk/templates/source/recent_comments_block.html
===================================================================
--- /trunk/templates/source/recent_comments_block.html	(revision 89)
+++ /trunk/templates/source/recent_comments_block.html	(revision 89)
@@ -0,0 +1,33 @@
+<{* **************************  usage ****************************
+ 	The template tag of the following list can be used. 
+ 		<{$block.data_count}>
+		<{$content.from_auther_to_post}>
+		<{$content.comment_ID}>
+		<{$content.comment_post_ID}>
+		<{$content.comment_date}>
+		<{$content.comment_date_time}>
+		<{$content.comment_content}>
+		<{$content.comment_excerpt}>
+		<{$content.comment_link}>
+		<{$content.comment_title}>
+		<{$content.comment_title_link}>
+		<{$content.post_link}>
+		<{$content.post_title}>
+		<{$content.post_title_link}>
+		<{$content.author_link}>
+		<{$content.author_name}>
+		<{$content.author_name_link}>
+		<{$content.comment_type}>
+   ************************* End of usage ************************ *}>
+<{* Start Template *}>
+
+<div id="xpress_recent_comments">
+	<{$block.data_count}>
+	<{foreach from=$block.contents item=content}>
+		<ul>
+			<li><{$content.from_auther_to_post}></li>
+			<li><{$content.comment_excerpt}></li>
+			<li><{$content.comment_date_time}></li>
+		</ul>
+	<{/foreach}>
+</div>
Index: /trunk/templates/source/recent_posts_content_block.html
===================================================================
--- /trunk/templates/source/recent_posts_content_block.html	(revision 89)
+++ /trunk/templates/source/recent_posts_content_block.html	(revision 89)
@@ -0,0 +1,43 @@
+<{* **************************  usage ****************************
+ 	The template tag of the following list can be used. 
+ 		<{$block.data_count}>
+		<{$content.post_id}>
+		<{$content.post_title}>
+		<{$content.post_content}>
+		<{$content.post_date}>
+		<{$content.post_time}>
+		<{$content.post_date_time}>
+		<{$content.post_modified_date}>
+		<{$content.post_modified_time}>
+		<{$content.post_modified_date_time}>
+		<{$content.post_author}>
+		<{$content.post_category}>
+		<{$content.post_tags}>
+		<{$content.post_views}>
+		<{$content.comment_link}>
+		<{$content.trackback_url}>
+************************* End of usage ************************ *}>
+<{* Start Template *}>
+
+<ul class="xpress_recent_comments">
+	<{$block.data_count}>
+	<{foreach from=$block.contents item=content}>
+		<li>
+		<{$content.post_id}><br />
+		<{$content.post_title}><br />
+		<{$content.post_content}><br />
+		<{$content.post_date}><br />
+		<{$content.post_time}><br />
+		<{$content.post_date_time}><br />
+		<{$content.post_modified_date}><br />
+		<{$content.post_modified_time}><br />
+		<{$content.post_modified_date_time}><br />
+		<{$content.post_author}><br />
+		<{$content.post_category}><br />
+		<{$content.post_tags}><br />
+		<{$content.post_views}><br />
+		<{$content.comment_link}><br />
+		<{$content.trackback_url}>
+		</li>
+	<{/foreach}>
+</ul>
Index: /trunk/xoops_version.php
===================================================================
--- /trunk/xoops_version.php	(revision 88)
+++ /trunk/xoops_version.php	(revision 89)
@@ -106,5 +106,5 @@
 	'show_func' 	=> "b_". $mydirname . "_comments_show" ,
 	'edit_func' 	=> "b_". $mydirname . "_comments_edit" ,
-	'template'		=> 'recent_comments_block.html' , 
+	'template'		=> '' ,
 	'options'		=> $mydirname. '|10|30|0|' ,
 	'can_clone'		=> true ,
@@ -117,5 +117,5 @@
 	'show_func' 	=> "b_". $mydirname . "_content_show" ,
 	'edit_func' 	=> "b_". $mydirname . "_content_edit" ,
-	'template'		=> 'recent_posts_content_block.html' , 
+	'template'		=> '' ,
 	'options'		=> $mydirname. '|10|0|100||0' ,
 	'can_clone'		=> true ,
