Can't Call Method 'entry_based' on an Undefined Value

Generally you will see this as a longer error message, typically coming from the ContextHandlers.pm module, with a particular line number, something like this:

Can't call method "entry_based" on an undefined value at lib/MT/Template/ContextHandlers.pm line...

The message may seem obscure when you receive the message, but in actuality, it just means that you are using a template tag that the publishing process cannot handle. You just need to remove it (or replace it with a tag that will function properly).

One of the most common occurrences of this error is the use of the MTArchiveTitle template tag within an individual entry template. Even though it would make perfect sense to be able to use the MTArchiveTitle tag – you are in an archive, after all! – the tag doesn’t work that way, and you need to use the MTEntryTitle tag instead.

So change the tag, republish the template and you should be set.

If that is not the problem, locating the problem tag may be a bit more difficult – luckily Movable Type can help you out with error messages. Just review each of your templates by loading up each one and seeing if you have any errors when you are viewing them.

Unfortunately if you are using correct tags, just on the wrong template, it can be a bit more difficult to locate the problem. In that case, you might have to do a bit more digging – but this can generally get you on the right track.


Posted

in