Help - Search - Members - Calendar
Full Version: Rebuild buttons on the List Templates screen
Movable Type Community Forum > Other Product Discussion > Desired Features
billsuspect
I searched the pinned message, but this specific feature was not listed...

In the main List Templates screen, I'd like to see a rebuild button column for each templates. That way when I edit my linked template file outside of the MT interface, I can simply go to the List Templates screen and rebuild the specific template as I need to.

I may hack this out myself... maybe.
webgraph
Hacking it isn't that difficult: I just did it and it works perfectly!

I'm running the latest version (v2.63) so your mileage may vary if you are running an different version.

Here's what I changed:

You need to copy two sections of code out of the edit_template.tmpl file (in /cgi-bin/mt/tmpl/cms on my system) and paste them into the list_template.tmpl file:

From the JavaScript section in the tag:
CODE
function doRebuildOne (id) {
   window.open('<TMPL_VAR NAME=SCRIPT_URL>?__mode=rebuild_confirm&blog_id=<TMPL_VAR NAME=BLOG_ID>&tmpl_id=' + id, 'rebuild', 'width=400,height=200,resizable=yes');
}


Just paste those lines into the JavaScript section in list_template.tmpl

Next, take this line from edit_template.tmpl:

CODE
<input class="button" type="button" onclick="doRebuildOne(<TMPL_VAR NAME=ID>)" value="<MT_TRANS phrase="Rebuild">">


and paste it somewhere safe (you'll need to do some more editing of list_template.tmpl before you can use this code).

Next, in list_template.tmpl, find the table which displays the templates -- it contains the following lines of code:

CODE
<TMPL_LOOP NAME=OBJECT_INDEX_LOOP>

and

</TMPL_LOOP>


The code that builds this table is what you need to edit in order to add the REBUILD button.

Instead of describing what I did here, I'll just post the entire block of table code, before and after:

BEFORE:

CODE
<table border="0" cellspacing="0" cellpadding="3">
     <form>

     <tr>
     <td width="205"><img src="<TMPL_VAR NAME=STATIC_URI>images/spacer.gif" width="205" height="1"></td>
     <td width="177"><img src="<TMPL_VAR NAME=STATIC_URI>images/spacer.gif" width="177" height="1"></td>
   <td width="45"><img src="<TMPL_VAR NAME=STATIC_URI>images/spacer.gif" width="45" height="1"></td>
   <td width="45"><img src="<TMPL_VAR NAME=STATIC_URI>images/spacer.gif" width="45" height="1"></td>
   </tr>
     
     <tr>
     <td width="205" valign="top" bgcolor="#8199A4"><font class="title-no-padding"><MT_TRANS phrase="Template Name"></font></td>
     <td width="177" valign="top" bgcolor="#8199A4"><font class="title-no-padding"><MT_TRANS phrase="Output File"></font></td>
     <td width="45" valign="top" align="center" bgcolor="#8199A4"><font class="title-no-padding"><MT_TRANS phrase="Rebuild?"></font></td>
   <td width="45" valign="top" align="center" bgcolor="#8199A4"><font class="title-no-padding"><MT_TRANS phrase="Delete"></font></td>
       
     <tr>
     <td valign="top"><img src="<TMPL_VAR NAME=STATIC_URI>images/spacer.gif" width="1" height="1"></td>
     </tr>
       
     <TMPL_LOOP NAME=OBJECT_INDEX_LOOP>
     <tr>
     <td width="205" valign="top" bgcolor="#<TMPL_IF NAME=IS_ODD>EEEEEE<TMPL_ELSE>FFFFFF</TMPL_IF>"><font class="title"><a href="<TMPL_VAR NAME=SCRIPT_URL>?__mode=view&_type=template&id=<TMPL_VAR NAME=ID>&blog_id=<TMPL_VAR NAME=BLOG_ID>"><TMPL_VAR NAME=NAME></a><br></font></td>
     <td width="177" valign="top" bgcolor="#<TMPL_IF NAME=IS_ODD>EEEEEE<TMPL_ELSE>FFFFFF</TMPL_IF>"><font class="title"><TMPL_VAR NAME=OUTFILE></font></td>
   <td width="45" valign="top" align="center" bgcolor="#<TMPL_IF NAME=IS_ODD>EEEEEE<TMPL_ELSE>FFFFFF</TMPL_IF>"><font class="title"><TMPL_IF NAME=REBUILD_ME><MT_TRANS phrase="Yes"><TMPL_ELSE><MT_TRANS phrase="No"></TMPL_IF></font></td>
   <td width="45" valign="top" align="center" bgcolor="#<TMPL_IF NAME=IS_ODD>EEEEEE<TMPL_ELSE>FFFFFF</TMPL_IF>"><input type="checkbox" name="id" value="<TMPL_VAR NAME=ID>"></td>
   </tr>
     </TMPL_LOOP>

     <tr>
     <td colspan="4" valign="top"><img src="<TMPL_VAR NAME=STATIC_URI>images/spacer.gif" width="1" height="3"></td>
     </tr>
       
     <tr>
     <td colspan="4" align="right"><input class="button" type="button" onClick="doRemoveTemplates(this.form)" value="<MT_TRANS phrase="Delete">"></td>
     </tr>

     </form>

   </table>


AFTER:

CODE
<table border="0" cellspacing="0" cellpadding="3">
     <form>

     <tr>
     <td width="205"><img src="<TMPL_VAR NAME=STATIC_URI>images/spacer.gif" width="205" height="1"></td>
     <td width="177"><img src="<TMPL_VAR NAME=STATIC_URI>images/spacer.gif" width="177" height="1"></td>
   <td width="45"><img src="<TMPL_VAR NAME=STATIC_URI>images/spacer.gif" width="45" height="1"></td>
   <td width="25"><img src="<TMPL_VAR NAME=STATIC_URI>images/spacer.gif" width="25" height="1"></td>
   <td width="20"><img src="<TMPL_VAR NAME=STATIC_URI>images/spacer.gif" width="20" height="1"></td>
   </tr>
     
     <tr>
     <td width="205" valign="top" bgcolor="#8199A4"><font class="title-no-padding"><MT_TRANS phrase="Template Name"></font></td>
     <td width="177" valign="top" bgcolor="#8199A4"><font class="title-no-padding"><MT_TRANS phrase="Output File"></font></td>
     <td width="45" valign="top" align="center" bgcolor="#8199A4"><font class="title-no-padding">Auto-<MT_TRANS phrase="Rebuild?"></font></td>
     <td width="25" valign="top" align="center" bgcolor="#8199A4"><font class="title-no-padding"><MT_TRANS phrase="Rebuild"></font></td>
   <td width="20" valign="top" align="center" bgcolor="#8199A4"><font class="title-no-padding"><MT_TRANS phrase="Delete"></font></td>
       
     <tr>
     <td valign="top"><img src="<TMPL_VAR NAME=STATIC_URI>images/spacer.gif" width="1" height="1"></td>
     </tr>
       
     <TMPL_LOOP NAME=OBJECT_INDEX_LOOP>
     <tr>
     <td width="205" valign="top" bgcolor="#<TMPL_IF NAME=IS_ODD>EEEEEE<TMPL_ELSE>FFFFFF</TMPL_IF>"><font class="title"><a href="<TMPL_VAR NAME=SCRIPT_URL>?__mode=view&_type=template&id=<TMPL_VAR NAME=ID>&blog_id=<TMPL_VAR NAME=BLOG_ID>"><TMPL_VAR NAME=NAME></a><br></font></td>
     <td width="177" valign="top" bgcolor="#<TMPL_IF NAME=IS_ODD>EEEEEE<TMPL_ELSE>FFFFFF</TMPL_IF>"><font class="title"><TMPL_VAR NAME=OUTFILE></font></td>
   <td width="45" valign="top" align="center" bgcolor="#<TMPL_IF NAME=IS_ODD>EEEEEE<TMPL_ELSE>FFFFFF</TMPL_IF>"><font class="title"><TMPL_IF NAME=REBUILD_ME><MT_TRANS phrase="Yes"><TMPL_ELSE><MT_TRANS phrase="No"></TMPL_IF></font></td>
   <td width="25" valign="top" align="center" bgcolor="#<TMPL_IF NAME=IS_ODD>EEEEEE<TMPL_ELSE>FFFFFF</TMPL_IF>"><input class="button" type="button" onclick="doRebuildOne(<TMPL_VAR NAME=ID>)" value="<MT_TRANS phrase="Rebuild">"></td>
   <td width="20" valign="top" align="center" bgcolor="#<TMPL_IF NAME=IS_ODD>EEEEEE<TMPL_ELSE>FFFFFF</TMPL_IF>"><input type="checkbox" name="id" value="<TMPL_VAR NAME=ID>"></td>
   </tr>
     </TMPL_LOOP>

     <tr>
     <td colspan="5" valign="top"><img src="<TMPL_VAR NAME=STATIC_URI>images/spacer.gif" width="1" height="3"></td>
     </tr>
       
     <tr>
     <td colspan="5" align="right"><input class="button" type="button" onClick="doRemoveTemplates(this.form)" value="<MT_TRANS phrase="Delete">"></td>
     </tr>

     </form>

   </table>


As you can see, you need to add a new cell to each row which has 4 cells already, and change the width values, as well as change the COLSPAN=4 in the lower cells to COLSPAN=5.

That should be it! Just remember to put that JavaScript in the list_template.tmpl file, otherwise it won't work.

Of course, you should always back up your entire blog and any files you will be editing BEFORE hacking them :-)

If you blow up your MT installation as a result of making these changes, I'm not responsible ;-)

Cheers,

-Dan
billsuspect
wonderful!

i love a good cut & paste. smile.gif
jayant
You might also look at the feature of Linking files to a template.

there you just need to upload a file. the file will automatically reflect changes in the template.
cool funda!!!
billsuspect
QUOTE (billsuspect @ Apr 23 2003, 05:10 PM)
That way when I edit my linked template file outside of the MT interface, I can simply go to the List Templates screen and rebuild the specific template as I need to.

That's what started this... I wouldn't need the new buttons if I wasn't linking them, ya know?
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.