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.

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.

Pages

Powered by Movable Type 5.01

Fatal error: Smarty error: [in evaluated template line 4]: syntax error: unrecognized tag 'mtfeed' (Smarty_Compiler.class.php, line 580) in /nfs/c04/h04/mnt/66783/domains/geekmum.com/html/mt/php/extlib/smarty/libs/Smarty.class.php on line 1095