Friday, February 26, 2010

Bug with Fetch Method

I realized last night that I hard-coded the Fetch method to use localhost instead of the current webserver's name.

I am working to correct this now.

I will also re-run the simple, advanced, and email examples to make sure they work.

Tuesday, February 23, 2010

Version 1.1 Released

I've added the fetch method, and substr, number_format, ceiling, floor and round template variable modifiers.

(Actually, I already had a few of those modifiers in the code, but they weren't documented until now.)

I'm finished documenting, too. I added a couple of email examples, and improved the layout of the documentation for template variable modifiers.

I also fixed a bug with the floor and round functions.

Note: there is a bug with VBScript implementation of the round function. I think my function returns the correct mathematical value.

Saturday, February 20, 2010

Almost finished documenting

Adding the fetch method required me to create several examples. One of them is a customer receipt. It shows the customer address, lists items purchased, and calculates the total. It took a bit longer than I thought because I had to add some variable modifiers that PHP already has:

substr (3 functions)
number_format (3 functions)

Dermis can perform some calculations, but it's more particular about the formatting than I'd like: all of the variables and operators must be together; spaces are not tolerated:
{ assign var="fltSubtotal" value=$fltSubtotal+$rcdItem.price*$rcdItem.quantity }

If Smarty is this strict about formatting, I'll leave it there.

So, again, now that I'm finished with the customer receipt example, I'll resume documenting again! :)

Thursday, February 18, 2010

{assign} bug fixed

One useful purpose of the fetch method is to send an email based on a template. While documenting an example of this, I discovered that the {assign} tag couldn't handle variables in the value element:

{assign var="to" value="$to_firstname $to_lastname <$to_email>"}

I suppose you could call it a "new feature," but Smarty could do this already, so I'll just call this a bug fix.

If you'd like to ensure you get all emails, use the default modifier:

{assign var="to" value="$to_firstname $to_lastname <$to_email|default:'your.email@organization.com'>"}

Anyway, I'll now continue documenting how to use Dermis to send an email based on a template file.

Tuesday, February 16, 2010

Fetch is Fetching Now!

The fetch method is working now! I'm very excited!

Background: Fetch retrieves the HTML output of a template. It's like pouring the output into a variable.

This code:
strContent=objT.fetch("simpletest.tpl")
response.write strContent

... is equivalent to this code:
objT.display("simpletest.tpl")

It took quite a bit of thinking, but not really much code, to get it to work. I couldn't find ANYONE who figured out how to pass session variables to a different SessionID on the same localhost. But I did!

This makes it possible to construct an email message based on a template file. I uploaded the new .ZIP file, but I still need to update the documentation. Updating the documentation will take a bit more time, only because I want to replace the "Send Template Email Sub" extra with equivalent code and template. I hope to finish in a day or two. Whoo-hoo!

Thursday, February 11, 2010

Fetch

I've been coding for a few hours trying to add the fetch method, unsuccessfully. The roadblock I'm hitting is that I can't seem to figure out how to pass session variables from one script to another.

The fetch method is there, but it doesn't work. If you're brave, kindly try to get it working. If you do, I'll seriously consider partnering with you as a co-developer!

I've googled around, but I haven't seen someone pass cookies into a calling script. However, if it's possible at all, I figure I'm pretty close!

I'm wore out. No more today.

Wednesday, February 10, 2010

Bug Fixed & Fetch

Someone (an anonymous user) pointed out a bug with the {foreach} tag: the ".last" property was being set one iteration premature. It was an easy fix; I corrected it the same day (Feb. 1).

Whoever pointed it out, thank you!

I've postponed working on {config_load} for foreseeable future. Coding for it is pretty tough, and frankly, I see it rarely used in Smarty templates.

However, I'm pretty excited working on a fetch method. Basically, it will return the result of a template back to the caller. This is what the Smarty fetch command does.

strContent=objT.fetch("dates.tpl")

This would compile the template, execute it "invisibly," and return the output.

My initial tests shows that it won't work if your webserver is running on XP. It returns, "The requested resource is in use." This problem doesn't exist on Windows Server 2003.

Post your URL as a comment!