Filters in Mephisto
April 9th, 2007

I just spent a bunch of time fiddling with what should have been a simple change to a filter plugin for Mephisto. It’s the Lightbox Filter. If I can save anyone else from this annoyance, this blog entry will be worth it!
Basically, all I wanted to do was to change the filter so that it generated the markup <div class="gallery"> instead of <div id="gallery">. Should be darned simple. So I went into the filter and changed one litter word. Great! I then spent far too long trying to figure out why that didn’t work. I could do nothing to coerce Mephisto to NOT generate the code the old way!!
I tried all of these things:
- I cleared the cache
- I manually deleted the generated pages
- I stopped the webserver and started it up again
- I even went so far as to toss that plugin out of Mephisto entirely.
NO DICE
Finally the answer..
It turns out that Mephisto calls the filter to generate the results when you save the article. I was assuming that it happened when a call came in from the ‘net for that page.
My assumption went something like this:
- Markup is saved in database
- Request comes in to web server
- Mephisto translates markup into HTML and serves the page.
Really, what happens is this:
- Markup AND generated content is saved in DB
- Request comes in to web server
- Mephisto combines pre-generated HTML into the full page and delivers it.
Mephisto stores two copies of your article in the DB. One is the one you edit, and one is generated as soon as you save the article to the disk, ready to pack up and deliver to the web server. Smart move!
So the solution to my problem was really simple. Once I edited the filter, I just had to re-save the articles from the admin console. That caused the filter to get called again to generate the markup with my precious <div class="gallery">. Ahhh! Relief. Now let’s blog about that experience.
Lesson Learned?
Yes – the trusty book “The Pragmatic Programmer” admonished that a programmer should always understand his tools and never program by coincidence. I had assumed certain things about Mephisto that were incorrect and it cost me precious time. Now I know more about Mephisto and realize that I make more assumptions that I sometimes recognize. :)

Sorry, comments are closed for this article.