In the course of the most recent redesign of my website, I setup the various link lists on my site—Your Blogs, Favorite Sites, etc.—as separate weblogs that are fed into my main weblog. Anyone who has gone in and updated the templates in Movable Type knows what a pain it can be. By using a separate weblog for link lists with one entry per link, it is very easy to make changes to those lists.
The proper way to do this uses PHP. If you can’t run PHP on your server, you’ll need to modify this process slightly. Plus it won’t be quite as easy to keep things up to date. You’ll need to rebuild your site every time you want new links to show up.
These are both rather old topics and very likely someone has already come up with the same ideas I’m pushing pixels about right here, but just in case, I’m writing this. My version of the link list uses great ideas from both places with a little extra twist of my own. Here’s how I did it:
- Make an includes directory on your website. This process will create one or more files that will be included into your webpages. For the sake of being organized, I created this folder to keep these files separate. I called my folder “inc” and put it in the root level of my website with the permissions set to 755.
- Make a new weblog. In my case, I called it “MFTI Links”. Set the “Local Site Path” to the new includes directory you created, and the “Site URL” to your website’s URL, plus the includes directory. You can ignore the two Archive settings. But you should set the correct Timezone. Save your changes.
- In the Preferences screen of your Weblog Config, use the following settings: Default Text Formatting to “Convert Line Breaks”, Default Post Status to “Publish”, Number of Words in Excerpt to “0”, Preferred Archive Type to “No Archives”. Make sure all boxes in Publicity and Comment Configuration are unchecked. Set Allow Comments Default to “None”. Save your changes.
- In the Archive Files screen of your Weblog Config, delete all archives. Save your changes.
- Delete all your templates. Go to the “Templates” screen. Delete all Index and Archive-Related templates.
- Create categories for each of the different types of link lists you want. I created a category called “Blog” for my “Your Blogs” list and one called “Favorite” for my “Favorite Sites” list. Make as many as you want.
- Back in the Templates screen, make a new Index template for each category you just created. vova’s idea was to create one template and include all categories in it. This means when you insert your link list, everything is together. Sure it’ll be sorted with headings, but everything winds up together. So in my case you’d see “Your Blogs” and the list and then immediately below it, “Favorite Sites” and the list. If you create individual templates for each category, you can put them where ever you want. My “Your Blogs” list is in my sidebar while “Favorite Sites” is on my About page. As an example, my “Your Blogs” template is called “Blog Links” and the Output File is “bloglinks.php”.
- Use this code for the templates:
<h2>Your Blogs</h2> <ul> <MTEntries category="Blog" sort_by="title" sort_order="ascend"> <li><a href="<$MTEntryBody convert_breaks="0"$>" title="<$MTEntryMore remove_html='1' $>"><$MTEntryTitle$></a></li> </MTEntries> </ul>
Obviously you should change this to whatever is best for you. Probably the two most important things would be to put whatever title you want to the list between the
</h2>tags, and to change
category="Blog"to whatever your category is.
- Make some entries into your new weblog. This is the format:Title = Name of the webpage (i.e. Monsters from the Id)
Primary Category = The category mentioned above (i.e. Favorite)
Entry Body = The URL of the webpage (i.e. http://www.idmonsters.com/)
Extended Entry = The title that shows up when you hold your cursor over the link (i.e. Jon Michaels’ Weblog)
Excerpt = An optional number or letter for sortingThis last one is where my method really differs from the other ideas people had. In the code listed in step 8 above you’ll notice
sort_order="ascend". This will display the list in alphabetically my the name of the webpage from A to Z. Changing the sort order to
"descend"would list the links from Z to A. If you removed the code
sort_by="title"entirely, the list would be sorted by entry date. The final option is to use the code
sort_by="excerpt". This would allow you to order the list in anyway you wish. Use numbers or letters to rank importance. Want your friend’s site to be the first on the list? Put a “1” or an “a” in the Excerpt field.
- Add the PHP include to your main weblog’s templates. Use this code:
Change the “inc” to whatever directory you created in step 1. Change “bloglinks.php” to whatever you called the Output File in step 7. Then put the code in your sidebar or where ever you want the link list displayed. Make sure to include it in all necessary templates.
- If your site uses PHP files (with the .php extension), you’re all set to go. Rebuild all the pages and you’ll be up and running. If you have HTML files (with a .html extension) you’ll need to make a change to your .htaccess file. (Or create one if you don’t have it.) It should be sitting in the root level of your website. Open it in a text editor (or create it), and add these two lines:
DirectoryIndex index.html index.htm index.php AddType application/x-httpd-php .html .htm
This will let you process PHP code in your HTML files.
If you can’t run PHP at all on your site, you’ll need to rework this whole idea. Probably using the
<$MTInclude$> tag. And as I mentioned, you’ll have to rebuild your site every time you want new links to show up.