# Category: Joomla

## Publishing with Dates and Times in Joomla 3.x (and Time Zones, Too)

I love Joomla like I love my favorite sweater: it’s old, it’s ratty, but it’s comfortable and does its job marvelously. Unlike the sweater, it’s not easy to replace. Also unlike the sweater, I know how to teach it new things.

When publishing articles, Joomla insists on displaying the date in the format, “day Month year.” Nothing wrong with that, but I’d generally want the day of the week, too. And maybe the time in certain categories, like surfing.

It turns out it’s relatively easy to change the behavior, as it’s something the good people of joomla.org thought about (unlike the behavior of the Prev/Next button, that is hard-coded to follow category with no option to go through all articles chronologically).

Theory: the display of the date chunk is controlled in layout files stored under layouts/joomla/content/info_block. The info block we are interested in, in this case, is created_date.php. If you look at that file (it’s very short), you’ll notice that the relevant line is:

<?php echo JText::sprintf('COM_CONTENT_CREATED_DATE_ON', JHtml::_('date', \$displayData['item']->created, JText::_('DATE_FORMAT_LC3'))); ?>

In the process of writing an article about something that happened to me in the distant past (just over 25 years ago), I needed to put equations into an article. Not very complicated stuff, mind you, just some quantum mechanics. I promise QM is much easier to look at than some other, more elementary stuff that is much more complicated to typeset.

I wondered what the best approach would be. The original equations were typeset in TeX and fairly easy to reproduce in that language. I could do that, generate an image, and use it in the article. But you know me, the enemy of the good enough and focus on things at hand. I started looking at all the different options there were for inline equation typesetting in HTML. And man, there were tons of options!

Long story short, I settled on AsciiMath. It’s a really wonderful package, as it not only allows you typeset the equations you want, but also allows you to do so in a very intuitive way, without all the weird syntax you need to use in the other systems.

For instance, the equation I needed to typeset looks like this:{inlmath}

Psi (vec x, t=0) = cos alpha u_1(vec x) + sin alpha u_2(vec x), 0<alpha<pi/2

The code for it is simply:

Psi (vec x, t=0) = cos alpha u_1(vec x) + sin alpha u_2(vec x), 0<alpha<pi/2

## SQLite Support in Joomla

It’s been a while now that I’ve been eyeing the SQLite implementation of Joomla. There have been lots of teasers, so far, but never could I ever click on the “Select Database Type” field and enter, sqlite. Finally, I got sick of waiting on a release and decided to go solo. I would find out who was working on SQLite for Joomla, track them down, offer them encouragement and help, if needed cajole or threaten, and finally get a SQLite implementation that “just works.”

### Why Joomla and SQLite?

At first, I was hesitant to want that combination. After all, installing Postgres or MySQL is not really a big deal, especially considering that installation of Apache is still orders of magnitude worse. But then I found that I can start a Joomla instance just by invoking the php server process in the Joomla main directory – suddenly life on development servers was much easier.

If you don’t know what I mean, here the skinny: you can just unzip the Joomla download into any directory, change into it, and type: php -S localhost:XXXX. XXXX has to be a number above 1024, something like 8000. Then you can simply go to your browser, type in localhost:XXXX (again, same number as before) and you can start installing Joomla. Once you are done installing, you can simply go there again and test and test.

That means that if you had a way to store your database locally, with your Joomla files, you could simply copy the whole tree and have a different instance running. You would go to the copy, change the paths in the configuration file, type in php -S localhost:YYYY and off you go with your new instance.

Can’t run MySQL on your web host? Problem solved. Don’t want to install a database server just for the occasional glimpse at your files? No problem. Want to see how a change to your site is reflected on your underlying files? There you go!

## How Do I Get My Content Back?

Have you ever done that? Created a content item that is of sufficient length that your session expired? You hit "Save," Joomla tells you that you are not authorized to view the resource, and you are left there with a giant blog entry that is gone for good. You think.

I had that problem several times. Joomla could react a lot better to a session timeout than by making you lose hours of work, wouldn’t you think? It’s easy enough to fix, too. But we are not going to change the Joomla code right now just to find a fix from this impasse.

What can we do right here and now to save our content? Here is a short howto with a method that might work for you, just as it saved me from a bind several times.

## Updated com_weight

I just tried out my old component (written some time in 2005, amazingly): com_weight. It's a weight table written as a component for Joomla, as the PHP version of my programming test in different languages.

It all started with me trying to lose weight in preparation of going to the military, where I knew I was going to be subjected to a strict regime of workout. So I wrote something that kept track of how I was doing, since I really don't care about my weight otherwise.

The first incarnation was in Tcl/Tk. It was a standalone application/script, and it did its job pretty well. To this day, of all the versions it's the one that has the best UI. Later on I wanted a web-ready version and rewrote the script in Perl. At that point, I started realizing that the weight table had great potential as a test of a language and my skills in it, so I rewrote it in Java (ugly as sin) and then as Joomla component.

## Write locally, deploy globally (or: synchronizing Joomla sites)

Once in a while, I am somewhere where even my Verizon USB dongle can't help me get connected: in n airplane, in a remote location, in a nuclear bunker… In those cases, I would love to be able to work on my site, but how do I do that?

Enters Blogg-X, a nifty little Java app that allows you to edit content locally, and then synchronize it globally to a Joomla site. It even allows you to synchronize to multiple sites (or at least it allows you to write for multiple sites). See: that's what open source is all about! Problem solved!

## What is zoom.searchbot?

I just realized I had never published my zOOm searchbot!

As you probably know, a searchbot (search plugin in Joomla) is a piece of software that, given a search term, returns a list of pieces of HTML that correspond to search results. Of course I wanted my zOOm search results to show up whenever someone searches on my site, so I just wrote a bot to accomplish that.

So, I realized after the upgrade to Joomla 1.0.11 that just *MAYBE* my version 2.1 of zOOm was a *TAD* outdated and upgraded to slick new 2.5.1. Great job, guys!

I made everything work, imported my data into the new zOOm, and everything worked just fine – except for my favorite mambot, the trusted moszoomimglink, that delivers those saucy thumbnails that you have gotten used to in my posts.

Well, I went to work on the problem, quickly found out that the only issue was the invocation of the correct set of include files (which I found quite astonishing), and there we were.

## Fixed moszoomimglink for zOOm 2.5.1

Well, it was easier than expected to port moszoomimglink to the new release of zOOm! All you have to do is install the new mambot after disabling the old one… Well, ok, not that easy, I haven't had a chance to repackage it yet.

To make your life bearable, though, I can tell you all that needs to be changed is the initiation sequence. In the file moszoomimglink.php, there is a long list of statements like the following:

## Resurrecting the site after upgrade

Again, an upgrade to Joomla – and again the change to sef.php reported previously. These security holes in Joomla start being costly for anyone that has done even minimal customization, and it start becoming relevant to actually change the behavior of Joomla to not require that kind of customization.