Build All Templates Dynamically

build_dynamically_all.png

I really like the "Build All Templates Statically" option on the Templates page, however I really wanted a Build All Templates Dynamically option. I posted a feature request on the subject but I don't think it was taken any further, so I took the matter into my own hands, see the screenshot (click for larger image).

Open up MT/App/CMS.pm and search for the following block of text, line #4842.

} elsif ($dcty eq 'archives') {
require MT::Template;
my @templates = MT::Template->load({ blog_id => $blog->id });
for my $tmpl (@templates) {
$tmpl->build_dynamic($tmpl->type ne 'index');
$tmpl->save();
}
} elsif ($dcty eq 'custom') {

Add replace it with the following

} elsif ($dcty eq 'archives') {
require MT::Template;
my @templates = MT::Template->load({ blog_id => $blog->id });
for my $tmpl (@templates) {
$tmpl->build_dynamic($tmpl->type ne 'index');
$tmpl->save();
}
} elsif ($dcty eq 'all') {
require MT::Template;
my @templates = MT::Template->load({ blog_id => $blog->id });
for my $tmpl (@templates) {
$tmpl->build_dynamic($tmpl->name ne 'Dynamic Site Bootstrapper');
$tmpl->save();
}
} elsif ($dcty eq 'custom') {

If your mtview.php template is called something else, replace the red text above.

Next open up tmpl/list_template.tmpl and search for the following code (line 59)

<input type="radio" id="dynamic_none" name="dynamicity" value="none"<TMPL_IF NAME=DYNAMIC_NONE> checked="on"</TMPL_IF>/> <label for="dynamic_none"><MT_TRANS phrase="Build All Templates Statically"></label><br />

Add right after it the following

<input type="radio" id="dynamic_all" name="dynamicity" value="all"<TMPL_IF NAME=DYNAMIC_ALL> checked="on"</TMPL_IF>/> <label for="dynamic_all"><MT_TRANS phrase="Build All Templates Dynamically"></label><br />

There is a problem with this code. Currently I haven't yet figured out how to have the Build All Templates Dynamically option having the radio button selected if that is the option you had chosen before.

Next to ensure that the option remains checked after being selected, find

$param{dynamic_none} = $blog->custom_dynamic_templates eq 'none';

around line 1590 and add right after it

$param{dynamic_all} = $blog->custom_dynamic_templates eq 'all';

Once this Build All Templates Dynamically option has been selected, you will need to perform a full site rebuild.

1 Comments

Marshall said:
on Dec 30, 2004 8:27 AM | Reply

Thanks for the awesome how-to!

There is a problem with this code. Currently I haven't yet figured out how to have the Build All Templates Dynamically option having the radio button selected if that is the option you had chosen before.

Add the following to MT/App/CMS.pm after the "dynamic_none" line (1590):

$param{dynamic_all} = $blog->custom_dynamic_templates eq 'all';

Seems to work for me in my quick test.