Smarty Templates


I often spend a heap of time tweaking stuff on my blog, and these show up as hits in the Referrers list, as well as on Performancing Metrics, a system of tracking readership.

Now, it’s rather simple to stop your visits counting towards your stats.

First, visit your site, and ensure you are logged in. In your address bar at the top of your browser, type in javascript:document.cookie, and press return. Find the cookie entry that starts with wordpressuser_, and copy the garbage-looking string after it - this is the md5 hash of your server name - to the clipboard.

Find the location of your stat-gathering code. Before it starts, enter:

{if $smarty.cookie.wordpressuser_md5string != "username"}

and after it ends, enter:

{/if}

Make sure to replace md5string with your md5 hash!

This could also be used to have any text show/not show when you visit your own blog. Like Google AdSense ads, for instance.

View Comments (7)   RSS Feed for Comments on this Post

This post is a Blogsome specific post with information gleaned from HOWTO: Wordpress Visitor Count Plugin Using Metrics API. If you aren’t using Blogsome, then you’ll be better off visiting there.

If you are using Performancing Metrics as your system for tracking usage patterns, you may wish to have a counter of some sort. It’s possible to do this, safely and securely with just a little bit of Smarty.
(more…)

View Comments (0)   RSS Feed for Comments on this Post

This is a Blogsome specific version of the post that can be found at Hack Metrics for More Detail.

The default script that I modified to generate Performancing Metrics stats for my Blogsome blog has some pretty serious limitations. The main one is that there is no differentiation between single posts, and the various types of archive pages that can be view: Category, Author, and Date (which includes Yearly, Monthly and Daily archive pages).
(more…)

View Comments (0)   RSS Feed for Comments on this Post

I’ve created a Popular Posts page, so I can have a limited number of popular posts in the sidebar, and the title of the box they appear in linking to a page with all of the popular posts.

I’ll do the same with Recent Posts, since this will be a smaller list than Archives. Basically, it will be a list of the last 25 posts, rather than a list of all of them, or the complete text of any posts.

I’ve just had another thought: for search pages, I could do some fancy stuff with testing the URL for ‘/search/‘, and then generating a search from the remainder. Instead of having to wait for Rewrite Rules to be implemented. Hmm, interesting.

View Comments (0)   RSS Feed for Comments on this Post

The Smarty Modifier “Human Age” works well under Blogsome, I’ll ask the admins to install it.

It’s used like:

{capture name=pdate}{the_time d="U"}{/capture}
{capture name=cdate}{comment_date d="U"}{/capture}
{assign var=since value=$smarty.capture.pdate|human_age:$smarty.capture.cdate:true:2}

Then, where you want the data to go:

{$since} after the fact.

Note: this is not installed on the main Blogsome server yet.

However, you can already use:

{human_time_diff from=$smarty.capture.pdate to=$smarty.capture.cdate}

after having captured the dates. It isn’t quite as nice as the other version, as it only displays minutes/hours/days, but it will do for now.

View Comments (0)   RSS Feed for Comments on this Post

Michael, over at Binary Bonsai, has written about how he turns off Google Ads (or any other type of text) for readers who have commented.

No Ads for Regulars at Binary Bonsai

Here’s how to do the same thing at Blogsome, using Smarty Tags. Just before your Ad Block:

{if $comment_author == ""}

And then after, use:

{/if}

Then, readers who have commented on your blog won’t see your Advertisement(s).

This only seems to work on a Post page. For some reason the cookie isn’t checked on other pages. I’m still looking into this.

View Comments (3)   RSS Feed for Comments on this Post

There isn’t a way to tell Blogsome you are writing in a different language, but with things like dates, that are generated using Smarty tags, there is a way to replace the English words with those of your chosen language.

Where you’d normally use a tag like: {the_time d='l, j F Y'}, which would generate something like: Thursday, 23rd March 2006, you can set up your template with:

{capture name=the_date}{the_time d='l, j F Y'}{/capture}

Then, assign this captured text to a new variable, after translating each word you know might appear in the text using |replace:"old":"new", which you can repeat for each word.

For example, to replace all of the day names with their Spanish equivalent, and assign the result to $la_fecha, I used:

{assign var=la_fecha value=$smarty.capture.the_date|replace:"Monday":"Lunes"|replace:"Tuesday":"Martes"|replace:"Wednesday":"Miércoles"|replace:"Thursday":"Jueves"|replace:"Friday":"Viernes"|replace:"Saturday":"Sábado"|replace:"Sunday":"Domingo"}

Then, wherever you want to use {the_date} in the Spanish format: {$la_fecha}.

Obviously, you’ll need to repeat this for month names as well, which I will leave as an exercise to the reader.

View Comments (14)   RSS Feed for Comments on this Post

I’ve come across a couple of Smary Modifiers I want to have installed on Blogsome:

More available on:

Smarty Plugins Wiki

If there’s any more there anyone is interested in, leave a message and I’ll test them out. And then ask the admins to install them, if they work.

View Comments (0)   RSS Feed for Comments on this Post

I’ve never been really happy with the HTML-Smarty Mode file I downloaded for SubEthaEdit. It’s okay, but it loses the syntax styling on HTML elements, and doesn’t really do that good of a job styling the Smarty parts.

So, I’ve spent the last couple of hours hacking it to make it a bit better. I’d forgotten how hard it is to examine and understand regex codes, but I’m getting there.

It’s too late, and I’m too tired to finish it, but it is already better than the original.

And then I go to the SEE website, and see there’s a newer version. Luckily, it’s still missing a whole heap of functionality. That’s a new project for me to work on then.

My mode isn’t quite ready for human consumption, but I’ll keep working on it.

View Comments (0)   RSS Feed for Comments on this Post

I’ve made some changes on my blog template so Trackbacks are handled a little bit nicer: specifically, Trackbacks/Pingbacks now also get the “owner” class. I’ve also turned off Gravatars for Trackbacks/Pingbacks, since they don’t make that much sense. I’d like to use a favicon or something in their place, but I’m not yet sure how to do this.

At this stage, I’ve left in code so that the Gravatar for the Author Email will appear for owner trackbacks/pingbacks.
(more…)

View Comments (0)   RSS Feed for Comments on this Post

« Previous PageNext Page »