Skip navigation

Sign up | Lost password? | Help

Hello World

Practical programming... and stuff...

Posts tagged with "source code"

The best Smarty + Zend View Helpers solution!

, ,

Coming on again with the Smarty and Zend View related articles, let's this time take a look at how to get Zend's View Helpers running with Smarty.

Other examples for this that I have seen use a syntax like this: {helper helper=Url p='array(something)' p2=stuff}, which is kind of ugly and the array parsing is done with eval, and we know that Eval is Evil.

Wouldn't a more elegant solution let you use helpers just like you use Smarty plugins? In the style of just typing the name of the helper and simple parameters? Let's see how to make that happen!

Read more...

How to easily redirect PHP output to a file

,

Ever wanted to change where your PHP sends the output to a file instead of the browser?
I have, and it involved changing every echo and other printing statemenet to fwrite. But

there is a better solution to that...

Read more...

Design patterns: The Factory

, ,

In my post about the problems in Zend Framework implementation of the MVC pattern I briefly mentioned the factory design pattern and that it could be used to create a view factory.

In this post I'll explain the concept of the factory a bit further and provide an example view factory implementation for you. We also brush the singleton pattern a bit.

Read more...

Smarty + Zend_View, take three

, ,

I've seen two articles describing how to integrate Smarty with Zend_View, Integrating Smarty with the Zend Framework at Zend Developer Zone and Zend Framework: Using Smarty as template engine at Dmytro Shteflyuk's blog. Both of these are very outdated by now.

So here's take three on integrating Smarty with Zend_View, this time hopefully staying useful for a longer time since the Zend Framework has reached version 1 now.

In this post I will show you a way to integrate Smarty with Zend_View as a new subclass and how to use this class with the new ViewRenderer helper to automatically display templates.

Read more...

A second clock in the Windows tray?

,

Since I talk with many people who aren't finnish, I've sometimes had some problems with their timezones and such. You know, sometimes it's useful to know what time it is somewhere else.

You could of course just open up google and look up a page with the time for the place or change the windows timezone temporarily so the clock would show the correct time there...

But that's kind of annoying and time consuming, so I came up with a solution: Display a second configurable clock in the system tray!


Read more...

An easy way to remove nested elements in HTML

, ,

I've sometimes faced the problem: How to remove nested elements from HTML source.

You have two options:
- If it's well formed HTML, you can use XML parsing functions.
- If not, you're left with traditional string-parsing approaches.


When you think about the second option, you probably think of something that keeps track of how many opening tags we have gone past and how many endings, ie. the depth.

That is, however, very complicated compared to the approach I'm going to show you.
Today it struck me: why not do it in reverse?

Read more...

How to track your visitors with PHP

, ,

As mentioned in the previous post, How to improve your blog, in this post I'll demonstrate how to track the visitors of your site with PHP.

You should have some previous knowledge of PHP programming to understand the code and concepts.

Read more...

Having fun with the PC speaker

,

Last year I wrote a command line application which you could use to play "songs" on the PC speaker. I called it "beepage".

Now I wrote a new version of the application: Winbeepage.

It's a pretty simple Windows application that lets you use the mouse to play different sounds from the PC speaker.

Read more...

T9/SMS text input

, ,

Anyone who owns a mobile phone knows how you type SMS messages on them. Unless it has a qwerty keyboard, which is quite rare, it's pretty cumbersome.

Still, for some odd reason I made an app written in C# that lets you do that on Windows with Numpad.


Read more...