Version: 1.00, by Mutt
Developer Last Online: Mar 2013
Version: 2.2.x
Rating:
Released: 02-08-2002
Last Update: Never
Installs: 16
No support by the author.
I was getting my templates ready to upgrade to 2.2.2 and I came up with this idea. vbLinks set it's templates as part of the default set and needed to be changed over to custom templates.
the default templates are seperated into groups, but when you make a bunch of custom templates, wouldn't it be nice to have them be grouped as well? Anyway, it was really easy.
open template.php and scroll down to the "Start Modify" section
you'll see
$only['calendar'] = 'Calendar';
$only['emailsubject'] = 'Email Subject';
etc.
they are set up like this
$only['**begining of template title**'] = '**Group Title**';
name your template something like
links_firsttemplate
links_secondtempate
then with all the other $only[*] lines add
$only['links'] = 'vbLinks';
links is the begining of all the links templates and vbLinks is the title for the group of templates
maybe later I'll make a admin cp form to add the group titles but for now just add them to template.php
just making these changes would make the new groups show up under the default templates, but to make them appear in the custom section
find
PHP Code:
while ($template=$DB_site->fetch_array($templates)) {
if (!$donecustom) {
$donecustom=1;
echo "<b>Custom templates</b>";
}
if ($under) {
if ($lastunder!=$under and $lastunder and $shrink) {
echo "</ul></li>\n";
$shrink = 0;
}
$lastunder = $under;
if (!$shrink) {
echo "<li><a name=\"".urlencode($shortname)."\"><b></a>$under Templates <a href=\"template.php?s=$session[sessionhash]&action=modify&expandset=$templateset[templatesetid]&group=".urlencode($shortname)."#".urlencode($shortname)."\">[expand]</a></b>\n<ul>\n";
}
$shrink = 1;
if ($group!=$shortname and $group!="all") {
continue;
}
} else {
if ($shrink) {
echo "</ul></li>\n";
}
$shrink = 0;
}
(I just grabed this from the default template section)
thats it. now your custom template will be grouped as well.
whats real nice is say you added some custom templates that should be grouped with the default ones like new error message, postbit, or getinfo templates, they will not only get grouped with that group name under custom templates, but when you expand the default postbit templates, the custom postbit templates will be expanded as well.
If I missed something let me know.
Show Your Support
This modification may not be copied, reproduced or published elsewhere without author's permission.
Originally posted by FireFly It appears that if you group the last template under a category the category is not closed and this what happens (attached).
I couldn't care less but just thought I'd let you know.
I didn't duplicate this in my browser. But from your screenshot, I had similar indentation issues. The attached modified hack may correct this since some tags were left unterminatd.
I also enhanced the hack a bit by giving the anchor/target different values for the custom templates. (Expanding on a default template would jump me to the custom template group if it exists.) All same-named groups are still expanded, but at least the anchor gets you to the right spot.
The attached file is the same hack with two minor changes.
Originally posted by kippesp I also enhanced the hack a bit by giving the anchor/target different values for the custom templates. (Expanding on a default template would jump me to the custom template group if it exists.) All same-named groups are still expanded, but at least the anchor gets you to the right spot.
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:
// 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'");