Forumlar / Cotonti / Core Labs / page templates idea

GHengeveld
#31285 2011-11-02 11:50

I like your idea. Especially for 'system' pages this will be useful. Using page_text to insert the HTML is very dirty, inefficient and limited, so the addition of custom tpl files for individual pages is welcome.

Your implementation won't work (correctly), because it will break category tpl files. cot_tplfile will look for a template file matching page.myalias.mycategory.tpl, will probably fail, try page.myalias.tpl, maybe fail and finally return page.tpl. It will never look for page.mycategory.tpl anymore. You need an alternative approach. Try this:

if ($pag['page_alias'])
{
	$alskin = cot_tplfile(array('page', 'al-'.$pag['page_alias']));
	if (!strpos($alskin, 'page.al-'.$pag['page_alias'])) $alskin = '';
}
$mskin = ($alskin) ? $alskin : cot_tplfile(array('page', $cat['tpl']));
$t = new XTemplate($mskin);

Note that this is Siena code, not Genoa like yours, so you'll need to adapt it a little. I've also added the prefix al- to the filename to avoid confusion with category tpl files.