http://www.lykoszine.co.uk/modules/mydownloads/viewcat.php?cid=3
Good stuff, that.
tom wrote:
Any chance of being cheaky and asking for a link to show us a demo of your working progress.
Thanks
MithyT2 wrote:
How do you use that one?
recompileTemplate('pjreviews','pjreviews_index.html');
recompileTemplate('pjreviews','pjreviews_searchbox.html');
$xoopsOption['template_main'] = 'pjreviews_index.html';
function recompileTemplate($dirpath,$fileName) {
Global $xoopsDB,$xoopsTpl;
//1. get tpl_id based on filename
$sql = "SELECT tpl_id FROM ".$xoopsDB->prefix("tplfile").
" WHERE tpl_file = '".$fileName."'";
$result = $xoopsDB->queryF($sql);
list($tpl_id) = $xoopsDB->fetchRow($result);
//2. read file into memory
$path = XOOPS_ROOT_PATH.'/modules/'.$dirpath.'/templates/'.$fileName;
$lines = file($path);
$filecontents = '';
$count = count($lines);
for ($i = 0; $i < $count; $i++) {
$filecontents .= str_replace("n", "rn", str_replace("rn", "n", $lines[$i]));
}
//3. update tplsource with new template
$sql = "UPDATE ".$xoopsDB->prefix("tplsource").
" SET tpl_source =".$xoopsDB->quoteString($filecontents).
" WHERE tpl_id = ".$tpl_id;
if (!$result = $xoopsDB->queryF($sql)) {
return false;
}
//4. recompile template
include_once XOOPS_ROOT_PATH."/class/template.php";
xoops_template_touch($tpl_id);
return true;
}
MithyT2 wrote:
There is a smarty variable, which can force a compile ($force_compile if I am not mistaken) which does exactly that - but the problem is that the templates in XOOPS are moved to the database, so it needs a bit of extra work here.
but as you say, most code is written... maybe possible to extend to module area.
What is really a bitch is if you use a non-default template set on your site Cause on module update, it updates the default template in database only.
'theme_fromfile' - when set to "1", XOOPS automatically checks your theme files to see if they have been update; if so, database templates are updated