Tutorials

Article archive

This tutorial is sort of a part 2, following the Wallpaper Gallery Tutorial. I will show you how to use MT to maintain a Article Archive, like I am currently doing on Eliza-D.com. The archive is completely powered by MT and a few plugins. :)

You’ll need MT installed for this (only tested in MT 2.x - NOT GUARANTEED TO WORK IN MT 3.x!) on the site you want to use this one. I have only tested this on the MySQL version of MT. It will probably work on the Berkley version as well, but I haven’t tested it, so beware. This tutorial will also assume that you’re using PHP Headers and Footers on your site, although you can easily use it without these… It’ll just make your site a bit slower and less easy to maintain. If you’re not using PHP, just put in the full HTML coding in wherever I refer to include("header.php"); and include("footer.php");

  1. Log into your MT control panel and click the Create new Weblog link. Fill in the following information on the next screen:

    Weblog name: Articles
    Local Site Path: [the absolute path to your site should already be filled in, like /home/user/public_html/mt. Replace everything after the public_html bit with articles: /home/user/public_html/articles
    Site URL: [the URL to your site should already be filled in, but replace everything after your site’s URL with articles: http://yourdomain.com/articles/
    Local Archive Path: Fill in the same here as you put down for Local Site Path.
    Archive URL: Fill in the same here as you put down for Site URL.

    Click the Save button. Your blog has now been created.

  2. Open up your FTP program, and connect to your website. Create a new folder named articles, and CHMOD this folder to 777. This is needed to allow MT to put files in that directory.

  3. Switch back to MT. After you clicked the Save button in step 1, you should now be in the Weblog Configuration Screen for your new Articles blog. Click on the Preferences Link near the top of the screen. Change the following things:

    Default Text Formatting for new entries: Set this to Convert Line Breaks.
    Default Post Status: Set this to Publish.
    File extension for archive files: Set this to "php" (without quotation marks).
    Allow Comments default: Set this to Closed.

    Leave everything else the way it was and click save.

  4. Now click on the link next to Preferences that says Archiving. Make sure the Individual and Category boxes are ticked and click save.

  5. Go to Templates in the navigation bar on the left side of the screen and click the "Create new archive template" link. Under Template Name, fill in "Yearly Archive". Paste the below coding into Template Body:

    <h1>Yearly Archive: <$MTArchiveDate format="%Y"$></h1>
    
    <div align="center">
    <MTArchiveYearPrevious>« <a href="<$MTBlogURL$><$MTArchiveDate format="%Y/"$>"><$MTArchiveDate format="%Y"$></a></MTArchiveYearPrevious>
    
    :: <a href="<$MTBlogURL$>">Main</a> ::
    <MTArchiveYearNext><a href="<$MTBlogURL$><$MTArchiveDate format="%Y/"$>"> <$MTArchiveDate format="%Y"$></a> »</MTArchiveYearNext>
    
    </div>
    
    <p>Below are all <b><$MTArchiveYearCount$></b> articles for the year <$MTArchiveDate format="%Y"$>.</p>
    
    <ul><MTArchiveYear>
    <MTArchiveLoad><MTEntries sort_order="ascend">
    
    <li><$MTEntryDate format="%B %Y"$>:: <a href="<$MTEntryPermalink$>"><$MTEntryTitle$></a> (<$MTEntryCategory$>)</li>
    
    </MTEntries></MTArchiveLoad></MTArchiveYear></ul>

    And click Save. Now go back into Weblog Config > Archiving, and click the "Add New…." button near the bottom of the screen. Under Archive Type, choose Monthly, and under Template, choose Yearly Archive. Click add, and you’ll see it appear on the archive page. Tick the box next to Yearly Archive, and paste the following code into Archive File Template:

    <$MTArchiveDate format="%Y/index.php"$>

    Click save.

  6. Under Index templates, delete all templates except for the Main Index. Under Archive-Related Templates, delete the Date-Based Archive.

  7. Click on Main Index Template, delete all the coding currently in there and put the following code into it:

    <?php include("../header.inc"); ?>
    
    <h1>Articles Archive</h1>
    <div align="center">
    There are currently <b><MTBlogEntryCount></b> articles available.<br>
    <MTCategories>
    
    :: <a href="<$MTCategoryArchiveLink$>"><$MTCategoryLabel$></a>
    </MTCategories> ::<br>
    <br>
    <MTArchiveList archive_type="Monthly" lastn="1"><MTAgain>
    
    :: <a href="<$MTArchiveDate format="%Y"$>/"><$MTArchiveDate format="%Y"$></a>
    <MTArchiveYearPrevious><$MTAgainHere$></MTArchiveYearPrevious></MTAgain></MTArchiveList> ::
    
    </div>
    
    <h2>Newest Articles</h2>
    
    <MTEntries lastn="5">
    <ul><b><$MTEntryDate format="%B %Y"$> :: <a href="<$MTEntryLink$>"><$MTEntryTitle$></a></b> (<$MTEntryCategory$>)<br />
    
    <i>"<$MTEntryExcerpt$>"</i></ul>
    
    </MTEntries>
    
    <?php include("../footer.inc"); ?>

    Put in "index.php" under Output File, and click save. The code above assumes you have your PHP header and footer in the folder above the articles one, if this is not the case remember to change the path.

  8. Go back into Templates, and click on the Category Archive Template. Delete all the coding in there, and replace it with the following:

    <?php include("../header.inc"); ?>
    
    <h1>Category Archive: <$MTArchiveCategory$></h1>
    
    <div align="center"><MTCategoryPrevious>
      <a href="<$MTCategoryArchiveLink$>"> «
      <$MTCategoryLabel$></a> ::
      </MTCategoryPrevious>
      <a href="<$MTBlogURL$>">Main</a>
    
      <MTCategoryNext>  ::
      <a href="<$MTCategoryArchiveLink$>">
        <$MTCategoryLabel$>
      »</a></MTCategoryNext></div>
    
    <p>Below are all <b><$MTArchiveCount$></b> articles available in the <$MTArchiveCategory$> Category, sorted alphabetically.</p>
    
    <ul>
    <MTEntries sort_by="title" sort_order="ascend"><li><a href="<$MTEntryLink$>"><$MTEntryTitle$></a> (<$MTEntryDate format="%B %Y"$>)</li></MTEntries>
    
    </ul>
    
    <?php include("../footer.inc"); ?>

    Click save. If you had to change the path to your PHP header and footer in step 7, do it here as well.

  9. Go back into Templates again, and now choose the Individual Entry Archive template. Delete all coding in here as well, and replace it with:

    <?php include("../header.inc"); ?>
    
    <div class="nav"><b>The Articles</b>:   <MTEntryPrevious>
    <a href="<$MTEntryPermalink$>">« <$MTEntryTitle$></a> ::
    </MTEntryPrevious>
    
    <a href="<$MTBlogURL$>">Main</a>
    <MTEntryNext>
    :: <a href="<$MTEntryPermalink$>"><$MTEntryTitle$> »</a>
    </MTEntryNext>
    </div>
    
    <h1><$MTEntryTitle$></h1>
    <p><i>Published in <$MTEntryDate format="%B %Y"$></i></p>
    <$MTEntryBody$>
    
    <?php include("../footer.inc"); ?>

    The same goes for the headers and footers again, change them if they’re in another folder, and click Save when you’re done.

  10. Now, anyone who has used MT before, will have spotted a couple of tags in the above coding that they might not have seen before. That’s because we are using four MT Plugins to generate the Archive.  You’ll have to install the following plugins to get the above coding to work: ArchiveLoad, ArchiveYear, MTAgain, and Supplemental Category Tags. Unzip the zip files, and upload the .pl files in it to your MT plugins folder. This folder is located in the folder where you installed MT (the same folder that holds mt.cgi). If it’s not there, just create a folder named "plugins". Follow any other instructions for installing the plugins on the sites above, too. That’s all you need to do to install these plugins. Easy, eh? :)

  11. Now you are ready to start adding articles to your archive. Click on the New Entry in the navigation bar. Type in the name of the magazine (or website, etc) and the title of the article into the Title Field (Magazine: Article Title). Choose a category from the dropdown, or if there are no categories there yet, click the Add New Category option. In my archive, I created categories for Magazines, Newspapers, and Online. Then just paste the text of the article into the Entry Body field. You don’t have to insert any p or br tags, MT will do that for you. Remember to insert bold or italic tags where necessary though! Click Save, and when the page is fully loaded, change the year under Authored On to the year the article was published and click save again. And that’s all! New article added! :)

There are many other plugins you can add to the archive. You could, for example, install the Entry Referrers Script to keep track of how many times each article has been read, like I did here. You could even open up comments for each entry to allow visitors to leave comments on each article. :)

Again, the way I created an Article Archive in this tutorial is not the only way to do this. I’m sure there are many other ways to accomplish something similar in MT. But hopefully this tutorial taught you a bit more about the different uses MT is great for.

Comments

Error Comments are closed for this entry.