Templates problem in 2.0.14/15 from xoops.org

Date 2006-08-30 12:52:23 | Category: XOOPS

in englishin japanese
In 2.0.14 from xoops.org, the system of templates are modified.
You have to see just a function.

- Using tplset other than default ... DB template. (== XOOPS 2.0.13)
- Using default tplset ... FILE template. (no longer DB template!)
-- Try to read /themes/(your_theme)/modules/(dirname)/(templates) first. (1)
-- Try to read /modules/(dirname)/templates/(templates) second. (2)
-- Else the template will be blank ... (3)

It looks like compromise idea between Oreteki and XOOPS<=2.0.13.

But this makes some incompatibilities against some module does not have templates under (dirname)/templates/.
eg) wraps, bulletin 2.0 etc.

Thus I've just suggested imploved codes here. (red part)

-- Else read DB template ... (3)

Yo, Skalpa!
Can you hear me?
class/smarty/xoops_plugins/resource.db.php

function smarty_resource_db_tplinfo( $tpl_name ) {
	static $cache = array();
	global $xoopsConfig;

	if ( isset( $cache[$tpl_name] ) ) {
		return $cache[$tpl_name];
	}
	$tplset = $xoopsConfig['template_set'];
	$theme = isset( $xoopsConfig['theme_set'] ) ? $xoopsConfig['theme_set'] : 'default';
	
	$tplfile_handler =& xoops_gethandler('tplfile');
	// If we're not using the "default" template set, then get the templates from the DB
	if ( $tplset != "default" ) {
		$tplobj = $tplfile_handler->find( $tplset, null, null, null, $tpl_name, true);
		if ( count( $tplobj ) ) {
			return $cache[$tpl_name] = $tplobj[0];
		}
	}
	// If we'using the default tplset, get the template from the filesystem
	$tplobj = $tplfile_handler->find( "default", null, null, null, $tpl_name, true);

	if ( !count( $tplobj ) ) {
		return $cache[$tpl_name] = false;
	}
	$tplobj = $tplobj[0];
	$module = $tplobj->getVar( 'tpl_module', 'n' );
	$type = $tplobj->getVar( 'tpl_type', 'n' );
	$blockpath = ( $type == 'block' ) ? 'blocks/' : '';
	// First, check for an overloaded version within the theme folder
	$filepath = XOOPS_THEME_PATH . "/$theme/modules/$module/$blockpath$tpl_name";
	if ( !file_exists( $filepath ) ) {
		// If no custom version exists, get the tpl from its default location
		$filepath = XOOPS_ROOT_PATH . "/modules/$module/templates/$blockpath$tpl_name";
		
		if ( !file_exists( $filepath ) ) {
			return $cache[$tpl_name] = $tplobj ;
		}
		
	}
	return $cache[$tpl_name] = $filepath;
}





You can read more news at PEAK XOOPS.
http://xoops.peak.ne.jp

The URL for this story is:
http://xoops.peak.ne.jp/md/news/index.php?page=article&storyid=354