MTIfEmpty

Update: A 2.01 release of MT-IfEmpty is now available, which mainly adds support for dynamic publishing in MT 3.1x.

You can download this plugin here: mtifempty-2_01.zip.

Usage:

<MTIfEmpty var="EntryTitle">(untitled)</MTIfEmpty>
<$MTEntryTitle$>

Embedded expression support works like this:

<MTIfNotEmpty expr="[MTEntries days='1']1[/MTEntries]">
    We have fresh entries!
</MTIfNotEmpty>

TrackBack

TrackBack URL for this entry:
http://bradchoate.com/mt/feedback/tb/15

Listed below are links to weblogs that reference MTIfEmpty:

» How to make a quick links weblog in Movable Type from markpasc.org
Some directions. [Read More]

» Testing... from Vertical Hold
So I'm trying out Brad Choate's cool MTIfEmpty plugin to try and work around having posts with no category having [Read More]

» Goofing Off With Amazon from Pudding Time!
For no better reason than "I can," movie and book entries get a corresponding Amazon link now. It's courtesy MTAmazon and MTIfEmpty, which are Movable Type plugins. MT has an 'excerpt' field in each entry that I normally don't use. The MTIfEmpty plugin... [Read More]

» Step One from Simplicity and Chaos
Live in the Delirious Cool lists a way to make your archives easy on the eyes. Each entry then looks like this: 02/21/03 : Just Because : Comments (1) : Trackbacks (0) I've incorporated this in my master archives page, [Read More]

» Step One from Simplicity and Chaos
Live in the Delirious Cool lists a way to make your archives easy on the eyes. Each entry then looks like this: 02/21/03 : Just Because : Comments (1) : Trackbacks (0) I've incorporated this in my master archives page, [Read More]

» Step One from Simplicity and Chaos
Live in the Delirious Cool lists a way to make your archives easy on the eyes. Each entry then looks like this: 02/21/03 : Just Because : Comments (1) : Trackbacks (0) I've incorporated this in my master archives page, [Read More]

» Step One from Simplicity and Chaos
Live in the Delirious Cool lists a way to make your archives easy on the eyes. Each entry then looks like this: 02/21/03 : Just Because : Comments (1) : Trackbacks (0) I've incorporated this in my master archives page, [Read More]

» Not Empty from Simplicity and Chaos
Another use of Brad Choate's IfEmpty plugin: the MTIfNotEmpty variable. For entries with categories, I've enclosed category information in the MTIfNotEmpty tags. This way, I can say "this entry posted in x category" but not say anything at all (or [Read More]

» Upgrades from Anger Management Course
I upgraded to MT 2.63. It runs flawlessly. The main... [Read More]

» Changing Templates from FeralBlog
As I'm bringing in all my Blogger content, it's taking awhile to move all my entries into categories. I still wanted to have the nice link to the category archives at the bottom of posts that have it, and amazingly... [Read More]

» Changing Templates from FeralBlog
As I'm bringing in all my Blogger content, it's taking awhile to move all my entries into categories. I still wanted to have the nice link to the category archives at the bottom of posts that have it, and amazingly... [Read More]

» Meta-logging from aurophone
Or, if you prefer, "trackback whoring," but that's life. Just blogrolled Jeremy Hedley's weblog, Antipixel. His site is great. He's... [Read More]

» Full-Screen Monthly Calendar Archives from Confetti Falling
I've seen this around a few places, and went looking today for a tutorial for Full-screen calendars in Movable Type. My monthly archives are now nice big calendars with each day listing the titles of the day's entries. I also... [Read More]

» MT IfEmpty plugin from Ever Curious: Snippets
http://www.bradchoate.com/past/mtifempty.php [Read More]

» Useful MT Plug-ins from Bryce Yehl
MTMacros, MTIfEmpty, Validable, MTIndexEntries [Read More]

» MTIfEmpty plugin from Edith Frost
Just installed my second Brad Choate plugin, and sent my second Trackback ping. Fun fun fun! MTIfEmpty gives you an extra set of... [Read More]

» Movable Type trick from Petroglyphs
One of the (many!) nice things about Movable Type is its customizability. I didn't realize just how far that extended until today. I'd read previously in the MT UI that you can customize the output path for the archive files using Archive File Template... [Read More]

» MT Plugins Installed from Technology Updates
The following MovableType plugins were installed: From Brad Choate IncludeEx - Improves on MT’s Include tag by processing the included file for MT tags. MTAuthors - This plugin allows you to list the authors for your blog. You can also... [Read More]

» Atom 0.2 feeds from Confessions of a G33k
For giggles, I added the MT Atom 0.2 templates from dive into mark to the site. The site feed is... [Read More]

» Movable Type Entry URL Choices from Brainstorms and Raves
Some people using Movable Type use the entry titles for the individual entry URLs, which is also what I do for Brainstorms and Raves. This can be a fine solution toward the friendly URL idea; however, a potential disadvantage is that the URL can get un... [Read More]

» Cruft-free URLs in Movable Type from dive into mark
Inspired by Matthew Thomas and others, I endeavor to remove all cruft from my permalinks. [Read More]

» Cool URIs from GeraBlog
Ho dato anche io una sistemata agli URI del blog, seguendo le istruzioni di Mark Pilgrim [via zlog]. Da adesso i permalink dei miei post avranno la forma: http://michele.f2o.org/archives/YYYY/MM/POST_TITLE (oppure KEYWORD) Questo mi serve a tenere ordi... [Read More]

» Cool URIs from GeraBlog
Ho dato anche io una sistemata agli URI del blog, seguendo le istruzioni di Mark Pilgrim [via zlog]. Da adesso i permalink dei miei post avranno la forma: /archives/YYYY/MM/POST_TITLE Questo mi serve a tenere ordinata la directory degli archivi e... [Read More]

» Cool URIs from GeraBlog
Ho dato anche io una sistemata agli URI del blog, seguendo le istruzioni di Mark Pilgrim [via zlog]. Da adesso i permalink dei miei post avranno la forma: /archives/YYYY/MM/POST_TITLE Questo mi serve a tenere ordinata la directory degli archivi e... [Read More]

» Essential Plugins For MT from zlog - posts
Topic for today, Movable Type plugins. Installation of the following will result in a better MT experience: MTIfEmpty -- Brad Choate MTMacros -- Brad Choate MTSafeHref -- Gavin MTPerlScript -- Brad Choate MTPlural -- Jesper Lindholms SimpleComments -- ... [Read More]

» An Even Non-Funkier RSS 2 Template from Andrew Grumet's Weblog
I gave Brad's Non-Funky MT RSS 2 Template a try but it was still too funky for my aggregator, which choked on the resulting feed. So here it is folks, an even non-funkier template. Note that it requires Brad's very... [Read More]

» Indextest from Reference, Brainstorms and Raves
This site is an ongoing, evolving experiment in creating a visually appealing site that is also standards compliant, accessible, and still usable in older browsers. I also strongly support WaSP (Web Standards Project), the W3C, and the WAI (Web Accessi... [Read More]

» Emoticons from Pinging Knight
I don't actually plan to use these, but it was fun to implement them. [Read More]

» MTIfEmptyプラグイン from Memento
ここ数日、[the girlie matters] tips and tricksでいろいろ勉強させてもらっています。 [the girlie matters] tips and tricks: no comments yet using mtifempty Brad Choate: MTIfEmptyをつかったこのTipsを応用して、Individual... [Read More]

» fotos update from . cynics' - /mak'in-trash`/ .
did some _structural_ adjustments to the fotos site as I found out some deficiencies in the way some of my data is being used. [Read More]

» Master To-Do List from no fixed position / weblog
To be finished before launch:   FIRST PRIORITY: finalize archiving names/paths of archive files implement calendar-based master archive implement calendar include for the blog index and monthly archives clean up/structure CSS files customized sear... [Read More]

» MovableType :: If Empty Tags from Chatter
Brad Choate has created a most useful MT plugin. The MTIfEmpty and MTIfNotEmpty tags allow for some programmatic control in template files using only MT-style tags.... [Read More]

» Movable typeのコメントをオープンする方法。 from Hardcow
 以前も書いたタイトルなんですが、出来てなかったのでもう一度。下記URLのPlug-inを使用します。 http://www.bradchoate.com/past/mtifempty.php<MTIfNotEmpty expr="[MTComments]1[/MTComments]"> <div class="comm... [Read More]

» Getting a list of posts with no category from Neil's World
Here's how to get an editable list of posts which are not assigned to a category. [Read More]

» Update on the move from twist of fait accomplis
If you see this post, then the propagation of laze.net to a new server has reached you. Here's a quick summary of what's new and improved with our new web host: More space. And a lot of it (for much... [Read More]

» Cruft-free URLs from Cantoni.org Articles
I just reconfigured my Movable Type blog to use cruft-free URLs. The basic premise is to clean up your URL scheme by removing non-essential information, thus ensuring that your links will live on in the future as you evolve with... [Read More]

» Movable Type 2.65 released, version 3.0 details dangled tantalizingly from redemption in a blog
Movable Type 2.65 has just been released - mostly a bugfix release with a few added features. The mt-send-entry.cgi fix is included (it already was included in any MT 2.64 packages after the flaw was discovered and summarily fixed), of... [Read More]

» Atom and Movable Type from Don't Back Down
I took a look at the default template for an Atom feed, introduced in Movable Type v2.65. This template seems to be where much of the new stuff fits into the new release. Within the template, we see that there is a new date tag, MTEntryModifiedDate, to... [Read More]

» Movable Type PermaLinks solution from Bryan Helmkamp's Weblog
When I went searching for a way to make MT use good PermaLinks I found two (partially overlapping) techniques: Már Örlygsson's and Mark's. Both of them had useful information but neither did exactly what I wanted. Actually, Mark's site uses... [Read More]

» Movable Type PermaLinks solution from Bryan Helmkamp's Weblog
When I went searching for a way to make MT use good PermaLinks I found two (partially overlapping) techniques: Már Örlygsson's and Mark's. Both of them had useful information but neither did exactly what I wanted. Actually, Mark's site uses... [Read More]

» RDF Photo Annotation with Movable Type from ten years of us: meta
After scurrying around for a few weeks gathering information about all things metadata, I created a template to help automate my photo annotation. I owe a debt of gratitude to the folks in the foaf and rdfig IRC channels, who... [Read More]

» Hey! I am still alive! from Warnadunia.NET: Colorful
I am still alive, just a little bit busy lately... I mean many things to do here. I have to... [Read More]

» Hey! I am still alive! from Warnadunia.NET: Colorful
I am still alive, just a little bit busy lately... I mean many things to do here. I have to... [Read More]

» エントリー、コメントがびよ~ん from Blog Side Street
1時間もくだらない更新してた・・・。ふぅ。でも楽しかったり・・・。 さて、トップページやカテゴリーページなどにある 「続きを読む」を「続きを開く / 閉じる」に変えた。 試して... [Read More]

» エントリー、コメントがびよ~ん from Blog Side Street
1時間もくだらない更新してた・・・。ふぅ。でも楽しかったり・・・。 さて、トップページやカテゴリーページなどにある 「続きを読む」を「続きを開く / 閉じる」に変えた。 試して... [Read More]

» Optimising Movable Type for Google from The Daily Dump
For those that like to tinker, I found this enlightening post on optimising Movable Type for Google while looking for something else. A quick search found quite a bit on the topic (see links below). I decided to implement some... [Read More]

» Optimising Movable Type for Google from The Daily Dump
For those that like to tinker, I found this enlightening post on optimising Movable Type for Google while looking for something else. A quick search found quite a bit on the topic (see links below). I decided to implement some... [Read More]

» Optimising Movable Type for Google from The Daily Dump
For those that like to tinker, I found this enlightening post on optimising Movable Type for Google while looking for something else. A quick search found quite a bit on the topic (see links below). I decided to implement some... [Read More]

» Two More Plugins from David Yin's BLOG
今天,天气很奇怪,很忙,先是阴天,中午下了一阵小冰雹,间或有雷声,然后是小雨,到我下班的时候,是暴雨,现在是晚上10点半,天气晴朗。 扯了这些,讲讲在MovableType上新装的两个plug... [Read More]

» hacking movable type from the worlds' end
Welcome to "hacking movable type", the chronicles of my exploits with movable type."hacking movable type" is a working title only, as I am aware that there is a book out there with the same name, and I would hate for somebody to confuse us two.In addit... [Read More]

» introducing "hacking movable type" from the worlds' end
Welcome to "hacking movable type", the chronicles of my exploits with movable type. [Read More]

» How-To Include Tags in Your MovableType Blog from hyku | blog - Josh Hallett
A few friends have been having some issues including Technorati tags in their blogs so I thought I would put together a how-to of what I've done. The simple modifications I have made to my MovableType software makes sure that... [Read More]

» Hierarchical threaded comments; How I did it. from 河國榮, An Aussie in Hong Kong

My blog is a MovableType blog developed by Six Apart Ltd. They also have other blog systems. They're a very smart company. You can read about their products on their web site. Like many other sys...

[Read More]

14 Comments

Jason Mevius said:

Can this be used in combination with the MTAmazon plugin? I've been emailing Mr. Kalsey on the sourceforge mailing list, and he suggested that I ask you.

I'm trying to run a MTAmazon query and post a link to the item in question. If the query comes back blank, I would like to post some text saying something like 'Sorry, not found in Amazon'.

The text I've currently got going is:

<div class="buy">
<MTIfNotEmpty var="EntryExcerpt">
<a href="http://www.goodrecords.com/good/shopaff.asp?affid=31&code=<$MTEntryExcerpt$>">Buy at Good Records</a>
</MTIfNotEmpty>
<MTIfEmpty var="EntryExcerpt">
<MTAmazon method="Keyword" search="[MTEntryTitle] [MTEntryBody]" line="music" lastn="1">
<a href="<MTAmazonLink>">Buy at Amazon</a>
</MTAmazon>
</MTIfEmpty>
</div>

I've added in line breaks to make the code more readable. If I don't have anything in MTEntryExcerpt, it runs an Amazon query to see if it can be found there. If the query returns no results, the text output is '<div class="buy"></div>'.

Can you see anyway to force MTIfEmpty to recognize the Amazon query? Failing that, could the MTAddRegex command turn the output of '<div class="buy"></div>' into the text string of '<div class="buy">Not found in Amazon.</div>'?

Any ideas?

rayne said:

I would think this would be a thing in the MTAmazon plugin. That if the results returned was 0 you could set a config setting to display a particular message.

Morten said:

How about the MTElse tag at the end.

(not proper code, but you'll get the picture

MTElse "Nothing found..."

Morten said:

How about the MTElse tag at the end.

(not proper code, but you'll get the picture

MTElse "Nothing found..."

Morten said:

How about the MTElse tag at the end.

(not proper code, but you'll get the picture

MTElse "Nothing found..."

hubd said:

Using MTIfEmpty plugin I made a cool thing on my site that shows an emtyp clickable ballon if there are no comments and a "full" clickable balloon with a comment count if there are comments. thanks for your help.

Jonathan said:

Brad, I believe I could definitely use your help with this plugin in the Movable Type plugins forum. In the proper topic ("MTIfEmpty, MTIfNotEmpty, General-purpose IF tags for templating") I've made a couple of posts at the end of the 5th and beginning of the 6th pages but have received no responses. My username is jareha. I'd greatly appreciate your help (oh, and I think nytshade could as well). Thanks in advance.

Jonathan said:

Thank you so very much for the help Brad (plugin working smoothly now). I'd attempted what you suggested before, but with one small difference (I was using double quotemarks). Maybe if you could note this is the plugins documentation for others? I've been stuck (until you just helped me) for weeks.

Thanks again! And great plugin by the way...it's serving my purposes quite nicely, as of late. :)

David said:

Brad,

I posted Stephan at nonplus.net about this yesterday. Maybe you see this as a plug-in idea.

An enhancement of Search that enables a short Form (with variable purposes) to be matched up with someone else's blog posting that fills out the same form. And the ability to email both when matches are made.

It would be used like this: A password-protected account holder, in my case a real estate broker, logs in, and fills out a quick form available on their log-in page. Just click a few boxes or select from a list. A new house offering on the market has 3 bedrooms, 3 baths, 2 floors, 1 swimming pool, & in the $170,000 sale range. The account holder's template automatically has the contact info and name, unless it is overriden by another contact name and number, email, etc.

Comments can have additional sales details.

Publishing this by the Real Estate agent simultaneously fills-in the fields on a standard visible "Classified Ad" included in the text of that blog post. Publishing also puts in motion an internal search function that tries to match up this form data with any other entry made by Jane Q or John Q Public within the last week or so right up to now.


Likewise, when Jane Q Public first checks out this Real Estate blog she uses a Search function on the Index page by first filling out the Real Estate form listing her house buying preferences. The values she has to select from are the same as the Real Estate Agent's form. Her search then produces all of the appropriate Posts chronologically whose attached form matches her requirements. And, if the search turns up nothing, she can check to have herself emailed when and if a new property is posted that matches her form.

When a match or matches are made all those Jane Q Public's who filled out the same form under Buying Preferences are automatically emailed that a matching profile has just been submitted on the market at our Real Estate Blog. Their email has the link to our Real Estate blog where they find a list of relevant postings ready to read. And each time a Real Estate agency posts with a match to their stored form query our Jane Q and John Q House-looking Publics will be emailled to come take a look.

And the Administrator can control the expiration of this query after a certain period of days or hours.


This same function can be used for a Personal Blog where people go on a Blind Date or something like that. Everybody fills out a form and asks for a match or an email when one shows up.

Lots of uses-- recipes, books, video tapes, collectibles, special interests.

I believe Brad "Almighty" Choate finds this well within the realm of his peerless Perl powers.

By the way, I am running 2.64 on a Linux OS Apache server with PHP and mySql databases.

Thanks for your consideration!

Hey Brad, the readme refers to "regex.pm" instead of "ifempty.pm" in the installation paragraph.

kal said:

Why is there no 'else' condition in the IfEmpty plugin... or is there one?

JP said:

Hi Brad,

Thanks for this article, I have been building website on MT whole weekend and I really love it.

I came up with small issues on category name. If my category contains Spanish characters or other links wont work on Internet Explorer. However Mozilla does a job perfectly but IE doesn't find a page.

JP said:

Ups, post into wrong category entry. I meant to post previous message into Doing whole site with MT article. :)

Ko Tun Kwan said:

Writing If...Else statement in movabletype

Can someone please help me?

I am trying to determine how to identify my archive link so that I can then select which menu structure to show.

Example: url1="country/country_entertainment/" and url2="country/country_sports/"

If str(url) contains "entertainment"
then hilite (menu_ent)
elseif str(url) contains "sports"
then hilite (menu_spt)

I know there is a MTElse...but then how do I get the individual url1 and url2 without getting all the category urls?
And how do I check if the url returned have either "entertainment" or "sports"?

Ps. My name is Tun Kwan, student from Sabah Tshung Tsin Secondary School, Malaysia

About

This article was published on October 20, 2004 12:35 PM.

The article previously posted was 2004, the year stuff happened.

The next article is MT-DSBL - Open proxy comment filter.

Many more can be found on the home page or by looking through the archives.

Powered by Movable Type