Categories
Just Shelley

Stubborn old farts run in my family

Recovered from the Wayback Machine.

My Dad is a remarkably stubborn old fart. His surgery yesterday was I guess rather harrowing for all involved, but as my brother said, my Dad came out looking better than the surgical team who had to fight to keep Dad alive. Dad always did like to make trouble for the doctors.

Mike said he doesn’t look bad today all things considered. He now has a one foot long metal rod in his leg to provide stability. It’s a good thing he can’t fly anyway, because wouldn’t he set off the alarms now. Frankly, though, if he were questioned for being a possible terrorist, I think he’d be rather flattered about the whole thing. At his age and all.

He’s still in intensive care until tomorrow, as I guess the danger time for surgeries, especially for older people, is 1 1/2 to 2 days.

My roommate will be home today, and I’m heading over tomorrow to see Dad, have lunch with my brother.

I sometimes forget, sitting in the isolation of my room or out on my solitary hikes, that I have connections with people: family and friends. Tenuous threads that have a habit of getting caught up on life now and again, providing a good, swift yank as you march blithely along.

Categories
Weblogging

WP to MT: Template engine or function call

When exploring the differences between the dynamic version of Movable Type and WordPress, it’s easy to get caught up in the one using a template engine and tags and the other using function calls. Those who support tags will say, and rightfully, that actual PHP code in a template can be intimidating to non-techs; but those who support function calls say, and rightfully, that template engines add an extra layer of processing to the application.

A template engine parses the template and generates an intermediate page that replaces tags with actual function calls. The reasoning behind doing this is to separate the presentation from the processing, in this case separate the PHP processing from the (X)HTML. Movable Type uses one of the more well known engines, the Smarty template engine, to handle the tag parsing in its new dynamic architecture.

However, a criticism of Smarty is that it doesn’t separate the processing enough, and can add it’s own level of complexity, as demonstrated in this small example from the Smarty site:

<html>
<head>
<title>User Info</title>
</head>
<body>

User Information:

Name: {$name|capitalize}<br>
Addr: {$address|escape}<br>
Date: {$smarty.now|date_format:”%Y-%m-%d”}<br>

</body>
</html>

But then, all template tag systems have some level of complexity if they’re going to be any use. At least for experienced MT users, they don’t have to learn another set of tags: Six Apart’s developers have extended the Smarty class to ‘translate’ so to speak, between MT’s tags, and Smarty’s. All combined, when you put something like this in a MT template such as Main Index:

<MTEntries lastn=”10″>
<div class=”sidecomments”><a href=”<$MTEntryPermalink$>”><$MTEntryTitle$></a></div>
</MTEntries>

After transformational magic, you get:

<?php $this->_tag_stack[] = array(’MTEntries’, array(’lastn’ => ‘10′)); smarty_block_MTEntries($this->_tag_stack[count($this->_tag_stack)-1][1], null, $this, $_block_repeat=true);while ($_block_repeat) { ob_start(); ?>
<div class=”sidecomments”><a href=”<?php echo smarty_function_MTEntryPermalink(array(), $this);?>
“><?php echo smarty_function_MTEntryTitle(array(), $this);?>
</a></div>
<?php $this->_block_content = ob_get_contents(); ob_end_clean(); echo smarty_block_MTEntries($this->_tag_stack[count($this->_tag_stack)-1][1], $this->_block_content, $this, $_block_repeat=false); } array_pop($this->_tag_stack); ?>

Looks like templates engines make the code a whole lot simpler. But then, look at what you use with WordPress to get the same result:

<?php get_archives(’postbypost’, 10,’other’, ‘<div class=”sidecomments”>’, ‘</div>’, 0) ?>

One of the challenges with a template engine is that you have to account for variations in what people want. This usually means having to build template starting and ending blocks, modifiers, and so on so you can get somewhat complex template tag use. However, with straight function use, you just pass all of this user defined options in as parameters.

As you can see, straight function calls can be simple, and template tags can be simple: it’s how each are integrated into the page that makes the difference. What I think is more important isn’t which approach is used, but how clean the end result is, and how extensible is the underlying architecture. And in these, both Movable Type and WordPress excel, especially with some of the new design considerations with WordPress 1.3. and the intermediate step taken to handle template tag differences between MT and Smarty in the new MT 3.1.

(Weird naming synchronocity, eh?)

(I’ll cover other ‘clean’ tools when I get into porting the Movable Type weblogs.)

As for extensibility, both Movable Type and WordPress are known for their plugin environments, though there has been some criticism of MT’s new PHP plugin environment–existing Perl plugins don’t work with it. However, with Six Apart’s use of the ezSQL database library in addition to Smarty, WordPress plugin authors may now have a new venue for their efforts.

For instance, I have a plugin in WordPress that provides the recent trackbacks, pingbacks, and comments, in one list in my sidebar. I also provide the URL for those who comment, which is why I don’t use the packaged comment functions.

WordPress uses ezSQL for database access, a simplified database API. So does MT for its PHP plugins. Because of the similarity, I could take much of my existing WP plugin and just port it over to MT. The code for the plugin I ported to MT can be downloaded here.

Key code differences, aside from the database structures that set the MT plugin apart from the one in WordPress is the function name, how the database connection is accessed, and the generated text output. Smarty requires that all objects have file names that reflect their nature, such as ‘function.’ for functions, and ‘modifier.’ for modifiers, and so on. The next part of the name is the actual tag element name that’s used in the template, using MT naming conventions, starting with “MT_”. The tag in this case is MTCustomComments. Since the plugin is a function, the file is called “function.MTCustomComments.php”, and the function is named smarty_function_MTCustomComments, the ’smarty’ also being a requirement for the function name within the template system.

Two parameters are passed, ‘$args’ representing any arguments passed to the function, and a reference to the Smarty context, ‘&$ctx’. Looking in the code, you can see how the database connection, db, is accessed through the Movable Type object (that buffer between Smarty and MT), that’s part of the Smarty Context:

$lines = $ctx->mt->db->get_results($sql);

One other difference is that rather than print out the result directly in the function, as I do in WP, I return a string, which is then output automatically within the template. I could do the same with the WP plugin if I was seeking to minimize differences between the environments.

To install the MT plugin, I created a sub-directory called ‘plugin’ in the PHP directory, loaded the new function file into it, and it’s ready to use. In the Main Index page, I then invoke the plugin as follows:

<$MTCustomComments$>

Any PHP function, Smarty Plugin, and even WordPress plugin could be adapted quite easily to the new Six Apart dynamic environment. And this also means that a Six Apart plugin could be easily adapted for use in WordPress. In fact, it wouldn’t take much to create tool-specific wrappers to wrap around functions so they can operate in both environments.

Not just MT and WordPress: let’s not forget other PHP systems with plugin environments, too.

The possibilities are intriguing.

Categories
Stuff

Mixed up world

Don’t you just love the days when I post like I do today? Lots of posts, first technology than politics than tech than politics? What I need is something gentle and reflective, to sweeten what is a relatively bold and saucy collection of writings.

I haven’t been out this week on walks or taking photographs, but did get some film back from the lab with previous trips to the Botanical Gardens. Though I know you’re all deadly tired of reflective pools and such, there are a couple of images from the group that provide a different viewpoint than previous submissions.

I’m also thinking of following Molly’s example with my own Request for Marriage Proposal (RFMP). But I want somebody rich. And old. Who will help me keep Burningbird going in the manner to which we’ve become accustomed.

What say you lonely older guys? Grow ever older with me…the best is yet to be. I may not be young and nubile, but at least I don’t wear rhinestones. I won’t make you clean your feet when we come in from a walk, but you’re on your own when it comes to cleaning the footprints. And I’ll never say to you, “Why don’t you…”

“One must never enter into the relation of marriage. Husband and wife promise to love one another for eternity. This is all fine, but it does not mean very much. . . . Such being the case with marriage, it is not surprising that the attempt should be made in so many ways to bolster it up with moral supports. . . . When two beings fall in love with one another and begin to suspect that they were made for each other, it is time to have the courage to break it off; for by going on they have everything to lose and nothing to gain.”

Kierkegaard

… I believe a kiss comes nearer the idea when a man kisses a girl than when a girl kisses a man. When in the course of years there has come about an indifference in this relation, then the kiss has lost its significance. This is true about the domestic kiss of marriage with which married people, apparently in lieu of a napkin, dab each other’s lips as the man mutters the ceremonial thanks, “That was swell, Mother.”

Kierkegaard

“If it is ridiculous to kiss an ugly girl, it also is ridiculous to kiss a pretty one, and the notion that doing a thing one way is any justification for laughing at a person who does it another way is nothing more than superciliousness and a complot, which does not, however, avail to set such a snob outside the category of the ridiculous, which is determined by the consideration that nobody can say what it means to kiss, although it is assumed to mean that the lovers desire to belong to one another for all eternity, yea, what is still more amusing, it is supposed to give them assurance of this.”

Kierkegaard

Categories
Healthcare Political

Need

Another thing that Bush talked about yesterday was how it was ‘junk lawsuits’ that are driving the cost of medical care up so high that health insurance costs have grown beyond what the average person can afford. If it weren’t for the fact that people sued doctors and hospitals, why everyone would have access to health care now.

That’s good to know. My Dad fell yesterday and broke his hip and has to have it operated on today, not something that’s lightly done when you’re 93 almost 94 years old. Luckily he has medical insurance to cover most of the costs of this, because his assisted living expenses are eating up his savings. Not to mention all the drugs the doctors keep giving him, though most don’t do a bit of good.

But I want to assure President Bush that if Dad dies during treatment, we won’t hold the hospital responsible and sue them. In turn, will he then get the health insurance premiums lowered in this state so that I can afford to get coverage? It would be nice not to be worried about getting sick. And if I am sick, it would be nice to know I could go into the doctor without being financially ruined by the trip.

But I’m a little lost on the mapping between limiting malpractice suits and available, affordable health care for all. Could he spend a little more time on that one?

Watching Bush yesterday, among that crowd of just plain folk, I thought that he came off rather charming. Likeable even. You know, I don’t think President Bush is evil. I think he grew up in an environment where people are supposed to take care of themselves and their friends and family, not have the government do it. I think he was taught that when people have a run of bad luck, it’s up to them to make the best of whatever situation they’re in. He grew up believing that every little boy or girl, well, maybe just every little boy, could be president someday. After all, just look at him? His Daddy was President, and now he’s president. Things work out, his brother will be president in four years. That’s the way these things work.

I think growing up he looked out on his father’s horse ranch and he saw wide open skies and plenty of green, so he didn’t understand why people talk about Texas being one of the worst polluted states in the country. He listened to his Daddy’s friends as they talked about how this country is rich with oil and Nature, she’s a tough old broad and isn’t going to be hurt by a little drilling.

He was raised in Texas where you just don’t step on another’s man’s shoes, boy, unless you’re willing to pay the consequences. Al-Queda stepped on our shoes, but Saddam was going to, he just knew this – why can’t most of us make this connection? And now that we’ve found out that Saddam really wasn’t much of a threat to us, well, the President said recently that sometimes people make mistakes. The Democrats chortled over that one.

His approval ratings shot up three points after that quiet bit of reflection. To the people here abouts, it takes a real man to admit he can make a mistake.

My own Dad didn’t grow up in a rich family, but he was brought up to believe that family takes care of family, and people don’t ask for help if they find themselves down on their luck. They make their own luck. Of course, it’s a lot tougher when your family isn’t rich, but that just makes the victory that much sweeter.

Dad also thinks that anyone that goes to live in a tree to protect it from being cut down is a nut, and those women who bare their pink bras to protest the war are silly, and pretentious. As for Iraq, well, he thinks it’s the Iraqi’s problem that they can’t see what a great opportunity they now have, and continue to fight among themselves. After all, government can’t do everything for them, either. Shame about our boys, though. And those nice foreign workers. The terrorists, they kill because they like to kill. They enjoy killing, and nothing we do will change this.

As for the cost, well everyone knows war is good for the economy. Look what WWII did for us?

If my Dad survives to November, which is iffy right now, and is capable of making cognitive decisions at the time, he’ll vote for Bush. I think that the President will appreciate that.

Categories
Political

Timing

President Bush was in Missouri yesterday, in Sedalia. That’s a friendly part of this state to Bush – solidly red.

He looked good during his talk, dressed in one of those cotton work shirts he tends to favor. Looked just like the people he was talking to. He said that in the next four years he plans on reforming the tax filing process, to make it simpler. Yeah, that’s something that we’re all worried about now – our taxes being too complicated.

He also focused a lot on the economy, and how tax cuts have helped and how people are doing better now than they were a few years back. I guess it was too bad, then, that Ford picked this day to announce it was laying off upwards of 800 employees at one its plants in the St. Louis area–another layoff in a series of layoffs that have hit this state since 2002.

But that President, he sure looks good in a cotton work shirt. Looks just like one of us.