Great hack !!!
Till now I used your old one adding groups to template.php, but this one is much better!!!
Thanks.
Just one thing. As I don't like to fix the templateid within the php code (it isn't ever done even for options template...

), I made this slight upgrade:
PHP Code:
// change
template.php?s=&action=customedit&templateid=xx
// into
template.php?s=&action=customedit&templatename=templategroups
// and
// change
$templates=$DB_site->query("SELECT templateid,templatesetid,title,template FROM template WHERE templateid=$templateid");
$template=$DB_site->fetch_array($templates);
// into
if (isset($templatename))
$templates=$DB_site->query("SELECT templateid,templatesetid,title,template FROM template WHERE title='$templatename'");
else
$templates=$DB_site->query("SELECT templateid,templatesetid,title,template FROM template WHERE templateid='$templateid'");
$template=$DB_site->fetch_array($templates);
What do you think about ?

Thanks again.