|
This is my second hack form Movable Type.
My inspiration for this was from
this thread on the MT Forums. Its not exactly what they were asking
for
but it was a fun lunch time hack. Not that useful but fun.
There are 5 Files that will need to be edited for this. As always make
backups before you start.
/lib/MT/App/CMS.pm
/lib/MT/Template/Context.pm
/lib/MT/Entry.pm
/tmpl/cms/edit_entry.tmpl
/lib/MT/Util.pm
Lets start with Util.pm
Open this file in your text editor of choice and find the lines:
@EXPORT_OK = qw( start_end_day start_end_week start_end_month
html_text_transform encode_html decode_html munge_comment
offset_time offset_time_list first_n_words
archive_file_for format_ts dirify remove_html
days_in wday_from_ts encode_js get_entry spam_protect
is_valid_email encode_php ); |
At the end of the last line add "my_temp" . It should then
look like this:
@EXPORT_OK = qw( start_end_day start_end_week start_end_month
html_text_transform encode_html decode_html munge_comment
offset_time offset_time_list first_n_words
archive_file_for format_ts dirify remove_html
days_in wday_from_ts encode_js get_entry spam_protect
is_valid_email encode_php my_temp); |
Next you'll need to add a new sub function. I added mine under the sub
is_valid_email
sub my_temp {
use SOAP::Lite;
SOAP::Lite
-> proxy('http://services.xmethods.net:80/soap/servlet/rpcrouter')
-> uri('urn:xmethods-Temperature')
-> getTemp(SOAP::Data->name('zipcode')->type(string =>
'75287'))
-> result;
} |
The only thing you'll need to change here is the '75287' to your Zipcode.
Sorry no international support that
I know of. I would also like to note that since SOAP::Lite is installed
with MT, there are lots of other cool
WebServices that could be used.
Nows Save and Close this file.
Open Entry.pm in your Editor of choice.
Search for the following line:
|
'title', 'excerpt', 'text', 'text_more', 'convert_breaks',
|
Under it add the following : 'temp',
It will look like this:
'id', 'blog_id', 'status', 'author_id', 'allow_comments',
'title', 'excerpt', 'text', 'text_more', 'convert_breaks',
'temp',
## Have to keep this around for use in mt-upgrade.cgi.
'category_id', |
Save and close the file.
Open Context.pm in your editor.
Search for the following Line:
And add my_temp at the end of it. It should now look like this:
use MT::Util qw( start_end_day start_end_week start_end_month
html_text_transform munge_comment archive_file_for
format_ts offset_time_list first_n_words dirify get_entry
encode_html encode_js remove_html wday_from_ts days_in
spam_protect encode_php my_temp); |
Now Search for this line:
| $ctx->register_handler(EntryDate => \&_hdlr_date); |
And Add this line directly under it:
| $ctx->register_handler(EntryTemp => \&_hdlr_entry_temp); |
You'll need to add the following Sub function, I added mine under the
_hdlr_sys_date
sub _hdlr_entry_temp {
$_[0]->stash('entry')->temp;
} |
Now Save and Close this file.
Now open CMS.pm
Search for this line:
Now add my_temp to the end so it looks like this:
| remove_html get_entry my_temp); |
Search for this line:
| $obj->convert_breaks(0) if !defined $q->param('convert_breaks'); |
Directly under this line Add the following:
my $y = my_temp();
$obj->temp($y); |
Now Save and close the file.
Now Open up edit_entry.tmpl
This is a little tricky to find the right spot so be careful
Find the lines that look like this:
</TMPL_IF>
</table>
</td>
</tr>
<tr>
<td bgcolor="#DDDDDD" colspan="<TMPL_VAR NAME=DISP_PREFS_BAR_COLSPAN>"><img
src="<TMPL_VAR NAME=STATIC_URI>images/spacer.gif"
width="1" height="7"></td>
<td></td>
<td bgcolor="#DDDDDD"><img src="<TMPL_VAR
NAME=STATIC_URI>images/spacer.gif" width="1" height="7"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="3"><img src="<TMPL_VAR NAME=STATIC_URI>images/spacer.gif"
width="1" height="3"></td>
</tr>
</TMPL_IF>
<TMPL_IF NAME=POSITION_BUTTONS_BOTTOM>
|
Now what you want to do is insert the in the Area I have marked in red
below
</TMPL_IF>
</table>
</td>
</tr>
<tr>
<td bgcolor="#DDDDDD" colspan="<TMPL_VAR NAME=DISP_PREFS_BAR_COLSPAN>"><img
src="<TMPL_VAR NAME=STATIC_URI>images/spacer.gif"
width="1" height="7"></td>
<td></td>
<td bgcolor="#DDDDDD"><img src="<TMPL_VAR
NAME=STATIC_URI>images/spacer.gif" width="1" height="7"></td>
</tr>
</table>
</td>
</tr>
INSERT HERE
<tr>
<td colspan="3"><img src="<TMPL_VAR NAME=STATIC_URI>images/spacer.gif"
width="1" height="3"></td>
</tr>
</TMPL_IF>
<TMPL_IF NAME=POSITION_BUTTONS_BOTTOM>
|
This is the code you will need to insert
<!----- begin ---->
<TMPL_UNLESS NAME=NEW_OBJECT>
<tr>
<td colspan="3"><img src="<TMPL_VAR NAME=STATIC_URI>images/spacer.gif"
width="1" height="3"></td>
</tr>
<td colspan="3">
<table border="0" cellspacing="0" cellpadding="0"
width="100%">
<tr>
<td bgcolor="#DDDDDD" rowspan="3"><img
src="<TMPL_VAR NAME=STATIC_URI>images/spacer.gif"
width="7" height="1"></td>
<td bgcolor="#DDDDDD" colspan="<TMPL_VAR NAME=DISP_PREFS_BAR_COLSPAN>"><img
src="<TMPL_VAR NAME=STATIC_URI>images/spacer.gif"
width="1" height="7"></td>
<td></td>
<td bgcolor="#DDDDDD"><img src="<TMPL_VAR
NAME=STATIC_URI>images/spacer.gif" width="1" height="7"></td>
<td bgcolor="#DDDDDD" rowspan="3"><img
src="<TMPL_VAR NAME=STATIC_URI>images/spacer.gif"
width="7" height="1"></td>
</tr>
<tr>
<td valign="top" bgcolor="#DDDDDD"><font
class="title">Temp:</font><br>
<input class="text-short" name="temp" value="<TMPL_VAR
NAME=TEMP>"></td>
<td valign="top" bgcolor="#DDDDDD"></td>
<td><img src="<TMPL_VAR NAME=STATIC_URI>images/spacer.gif"
width="1" height="1"></td>
<td bgcolor="#DDDDDD" width="33%">
<table border="0" cellspacing="1" cellpadding="2">
<tr>
<td valign="top"></td>
<td valign="top"></td>
</tr>
<tr>
<td valign="top"></td>
<td valign="top"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td bgcolor="#DDDDDD" colspan="<TMPL_VAR NAME=DISP_PREFS_BAR_COLSPAN>"><img
src="<TMPL_VAR NAME=STATIC_URI>images/spacer.gif"
width="1" height="7"></td>
<td></td>
<td bgcolor="#DDDDDD"><img src="<TMPL_VAR
NAME=STATIC_URI>images/spacer.gif" width="1" height="7"></td>
</tr>
</table>
</td>
<tr>
</tr>
</TMPL_UNLESS>
<!----- end ----->
|
This will add a new area that will show when you edit an entry, it works
just like the Authored on date.
Now the final step is to use this tag in your MT template, its per entry
so you could use it around the area where you post the time now.
Note that its only in Farenheit, and you'll need to add the F in your
template.
So now it should be working now, and looking like this.
Here is the Edit entry box:

And here is what it looks like in an entry:

|