Recently in MT Template Tags Category

Creating a "Sticky" Entry

Sometimes I want to make a post "sticky" so it stays at the top of my entry list for an extended length of time, even after posting newer entries. There are several ways to accomplish this.

One, perhaps the simplest, is to post-date the "sticky" entry so that it will stay in place as long as that date is still in the future or no entry has usurped it's place by post date.

Another option is to just hard-code the sticky text into your index template where you want it. (yuck, but it works)

A third option and my preferred method is to use the MTEntry plugin which gives you the MTEntry tag, allowing you to call one specific entry id...

MTLink

Use the MTLink tag in your Main Index (or wherever) to automatically generate an URL for a template module or blog entry...

to link to a template module:

<h2>About</h2> <div class="about"> <ul> <a href="<$MTLink template="About"$>">about me</a> </ul> </div>

OR to an individual entry:

<h2>About</h2> <div class="about"> <ul> <a href="<$MTLink entry_id="235"$>">about me</a> </ul> </div>

php includes in cgi templates

I wanted to use a php include in my Comment Listing Template, which is actually run inside comments.cgi. An ordinary php include wouldn't do the trick. Another plugin to the rescue... MTIncludePlus. This provided the perfect solution in the form of new container tag, MTIncludeURL. (FYI, this plugin also adds tags MTIncludeFile and MTIncludeModule.) Here's an example of what I used to call a rotating tagline into my banner in dynamic templates that run as cgi:

<MTIncludeURL timeout="15">http://domain.com/tagline/rotator.php</MTIncludeURL>

(obligatory reminder: code is all one line)

This also works in the default search templates.

php includes in dynamic archive templates

I was having a heck of a time calling includes into dynamic archive pages (php files, no extensions). The syntax I used in my Main Index template was NOT working in my dynamic archives. What I found out was that I was using a php shortcut syntax which is not enabled on all servers (and perhaps in my case not in all cases? not sure about that yet - I'll look into an .htaccess solution although I have no reason to believe there is one - just a gut instinct to try)

These worked in the main index, but not in archives:

<? include "http://domain.com/tagline/rotator.php"; ?>

or
<? include "tagline/rotator.php"; ?>

This syntax works in both index AND archives:

<?php include ("http://domain.com/tagline/rotator.php"); ?>

or
<?php include ("links.inc"); ?>

Cool.

Update: having a big "duh!" moment. Forgot about MTInclude as well as plugin MTIncludePlus. The latter provided a solution (new tag MTIncludeURL) for calling includes into my comments.cgi page. (comment listing template,etc) Here's an example of what I used to call a rotating tagline into my banner in dynamic templates that run as cgi:

<MTIncludeURL timeout="15">http://domain.com/tagline/rotator.php</MTIncludeURL>

(obligatory reminder: code is all one line)

NOTE: MTInclude and MTIncludePlus tags slow down the rebuild process. (I only use these tags when a regular php include won't do.) To speed up these tags, consider the MTFastInclude plugin at MTExtensions.

display categories in category archive

I want to display a list of categories in a sidebar on my Category Archive Template page. If I enter the code from the Main Index, my category archive sidebar comes up empty (literally, it displays nothing under the categories heading). To fix that, I am calling that same code into my category archive template as a php include.

Create a new index template called categories.php and place in it the sidebar code (from main index template) for your CATEGORIES:

<MTSubCategories> <MTSubCatIsFirst><ul></MTSubCatIsFirst> <MTIfNonZero tag="MTCategoryCount"> <li><a href="<$MTCategoryArchiveLink$>" title="<$MTCategoryDescription$>"><MTCategoryLabel></a> <MTElse> <li><MTCategoryLabel> </MTElse> </MTIfNonZero> <MTSubCatsRecurse max_depth="3"> </li> <MTSubCatIsLast></ul></MTSubCatIsLast> </MTSubCategories>

In your Category Archive template, place the following code:


<div id="categories">
<h2>MTInclude Categories</h2>
<$MTInclude file="categories.php"$>
</div>

This should display your category heirarchy just as in the main index. You could also use this method to display recent entries here. I do believe the entire sidebar code would work in your category archive using this method.

(extended entry below is my former not-so-brilliant method... don't bother reading it)

About this Archive

This page is an archive of recent entries in the MT Template Tags category.

MT Style Tweaks is the previous category.

MT User Interface is the next category.

Find recent content on the main index or look in the archives to find all content.