Heal Your Church WebSite


Teaching, rebuking, correcting & training in righteous web design.

Adding User-Defined Fields in Movable Type

Last month, when I was obviously distracted by something that seemed important at the time, Deane at Gadgetopia wrote an incredibly useful post entitled Adding User-Defined Fields in Movable Type.

Now I realize not everyone here uses the MovableType(MT) web logging tool, but for those of you, who like me, have customized MovableType into a content management system for your church website, Deane’s article offers that little bit extra you may need in the way of additional fields you need to get the job done.

Practicing what I preach, I decided to following Deane’s instructions and add some extra fields to blogs4God in the hopes of moving all the links under one MT roof. If successful, I could then double back and do the same for Redland where I am currently using the keywords field to associate several Scripture reference fields to each page/entry. Easier to do, but harder for others who don’t understand my system to maintain the pages. Deane’s solutions integrated with the current edit screen so new fields work and play just like the old ones, making complex entries easy as pie for even the most techophobic music minister.

My results? Well, for today, I only went after steps 1 through 4 and thirty minutes later, was 4 for 4 in the success department. Yes, I realize some of you are in shock it took me so long, but two things I offer in my defense. First, I added some steps to Deane’s, mainly backing up my data and the code modules. Second, a took step 3 one step further by modifying the entry preferences … that is a dialog box that allows me to select which fields I see on the MovableType entry screen. Which I messed-up on the first try, which was no problem, because I had a backup … you can too if you do this before you start:

cd $HOME/www/cgi-bin/mt
mkdir codebackup
cd codebackup
mysqldump -uUSERNAME -pPASSWORD –opt DBNAME > DBNAME.sql
cp ../lib/MT/Entry.pm Entry.pm
cp ../lib/MT/Template/Context.pm Context.pm
cp ../tmpl/cms/edit_entry.tmpl edit_entry.tmpl
cp ../tmpl/cms/entry_prefs.tmpl entry_prefs.tmpl

The above assumes that you have shell access to your system and that you’ve moved MovableType into the cgi-bin directory.

Other differences occured with where I placed some of my hacks. From Deane’s blog, it appears his line numbers may be a bit skewed due to prior hacks. My line numbers are based on the original files for MT version 2.64. Here they are:

  1. lib/MT/Template/Context.pm … my entry was placed on line 90
  2. lib/MT/Entry.pm, where Deane says line 17, my change occurs on line 22
  3. tmpl/cms/edit_entry.tmpl, Deane suggest line 433, my hack starts on line 400
  4. tmpl/cms/entry_prefs.tmpl, I have mods on line 116 and 152

As always, be aware, your mileage may vary. I entirely agree with Deane, these changes aren’t for the faint of heart.

I numbered the differences above because I want to show you the code for each of those hacks. First is my change to tmpl/cms/edit_entry.tmpl, or numero 3 on the list above.



Now onto a file named entry_prefs.tmpl. On line 116, you need to change the line that reads:

<td rowspan=”9″><img src=”<TMPL_VAR NAME=STATIC_URI>images/spacer.gif” width=”30″ height=”1″></td>

to

<td rowspan=”10“><img src=”<TMPL_VAR NAME=STATIC_URI>images/spacer.gif” width=”30″ height=”1″></td>

Then on line 152 of entry_prefs.tmpl, you add the following (don’t let the wordrap fool you):

<tr>
<td valign=”top”><font class=”title”><input type=”checkbox” name=”custom_prefs” value=”b4g_edit”<TMPL_IF NAME=DISP_PREFS_SHOW_B4G_EDIT> checked</TMPL_IF>> <MT_TRANS phrase=”blogs4God Link Editing”></font></td>
</tr>

Now all that is left to do is create another blog, port my data, modify the templates as per Deane’s most excellent instructions and viola, I’m done …

One Comment

  1. Awesome… Six Apart should definitely add this feature to MT. (I’m a little too “faint of heart”!

    (P.S. I can’t believe you quoted the Ventura County Star — my hometown’s local rag!)