Tuesday 24 November 2009

Handy MooTools script for phpBB3 inside a wrapper

For reasons that are too long to go into, a change between phpBB2 and phpBB3 was to make all links not include a target attribute to make the output meet relevant requirements.

On one site I manage (http://www.connectage.com) we have a forum inside a Joomla! wrapper. I'm sure you can see where this is going.

So to stop this happening, I wrote a MooTools script. This script ensures that links to our site open in the parent window (i.e. not the iframe) and other links open in a new window / tab.


<script src="../media/system/js/mootools.js" type="text/javascript"></script>
<script type="text/javascript">
window.addEvent('load', function() {
// send links to a new window, unless it is on our site
var postLinks = $$("div#pagecontent div.postbody a.postlink");

postLinks.each(function(link) {
var sendTo = '_blank';
if(link.getProperty('href').contains(window.location.hostname)) {
sendTo = '_parent';
}
link.setProperties({
target: sendTo,
rel: 'nofollow'
});
});
});
</script>


Simple as that.

There are two scripts there. 1 brings in the default Joomla! MooTools script, which is needed so the rest works.

The second bit, creates an array of links within posts only, checks the domain they're going to and sends them to the parent window (target='_parent') or a new window (target='_blank').

And because it's Javascript, I believe it's still standards compliant. It will also not stop your site working if someone has Javascript turned off in their browser.

This may not work on your template, but it should be easily adaptable if you need it for your own site.

Validated XML for Joomla!

http://docs.joomla.org/Official_DTDs

And better yet, if you're using Eclipse and put the information in (correctly), it will validate it for you. Might solve my current problem with a component not installing correctly.

Tuesday 17 November 2009

Menu Module Clone

I've written a Joomla! component. Here's a demo of it.




Here's the full listing.

Friday 9 October 2009

Mac Wireless

Well, that's interesting.


I upgraded to Snow Leopard, and everything was hunky dory. Probably because I had tied down any changes to the network by requiring an admin to do it (I'm the only one who uses the machine, but still, good practise. If annoying when you're installing stuff you want).


Then I moved house, and everything went haywire.


Symptoms:
- Unable to connect to a new network
- Unable to turn Airport off
- Unable to connect to old networks


That's all when logged into the Admin account. Anyway, the fix I found was here at technipages. I was trying to do something similar, but didn't know you could add a new location. I was sure it was something in the software, because when I logged into Windows XP in my bootcamp it did connect. 


Very weird, but all sorted. Now to go to a warm room, away from the router room (which is freezing!)

Wednesday 7 October 2009

Browser stats

For a while now, I've been talking about how IE6 is not needed support, and that IE7 is also useless.


Unfortunately, I was wrong. I've spent a bit of time doing some research on this, mainly through 2 sites. First up was w3schools.


As you can see, Firefox was unsurprisingly the top browser for visitors to the site. It's bleeding market share, probably to Chrome and Safari at a guess. Since this post is based on the fact I was wrong with an earlier guess ... take that with a grain of salt. Chrome and Safari are both increasing, something which I'm sure I've contributed to. But IE7 is still the top IE browser?? I didn't see that coming, especially on what is a 'tech' site. And 12% of all visitors STILL use IE6??? No wonder you need help with programming ....


Next, I went to statcounter. You need to dig down to find information, as the first page is pretty simple. What it does do, though, is show that IE6 and IE7 are not dying any time soon. Windows 7 may change that, but personally I doubt it. 


My favourite stat though, was mobile OS. The iphone is not number 1, which isn't too surprising when you know how many 'smart' phones there are out there running rival OSs. 


Anyway, the moral of the story is a) Aussie IE8 users will overtake IE7 this month and b) You still need to provide support for IE6 and IE7. For the rest of 2009 anyway. We'll see what the new year brings!

Tuesday 29 September 2009

Most Useful Joomla! extension ... ever?

JComments. Does everything it's meant to, and allows you to actually create a menu of type blog that is an actual blog!

Macrumors likes to have a forum entry for each of their news items, but with JComment I don't think that would be necessary. It really is great, and apart from possible problems with multi-lingual sites (which is a problem I'm just starting to run into) I can't see anything it can't do. It doesn't make the mistake of being too complex, and trying to do too much. 

If I was going to run a news site using Joomla!, I don't think I'd need anything more then a default installation, JComments and Community Builder.

What I use (and possibly, why?)

Computer

At home, it's a Macbook. The base model, it's been upgraded to have
4gb of RAM. I'd wanted one for a while, so when I moved to the UK, and
needed a small, easy to transport machine it was the obvious solution.
Especially as it had everything I needed already installed, and I
wasn't planning on playing any high-end games. It helped that I was
forced into using a Mac Mini at work, so I'd already been immersed in
the Mac way of doing things.

At work, it's a Mac Mini and a Dell Vostro. Neither of them is my
choice, but after trying to run a virtual machine on a Mac Mini with
1gb of RAM, I had to get a windows machine. And, sadly, it may
actually be more powerful then my Mac Mini. Still not as good as the
Macbook Pro that I'd like to use!

Browser of Choice

I flick between 3. Safari for general everyday things. It also has a
decent set of developer tools. Not as good as Firefox, which is great
because of Firebug. Last, there is Chrome. Used on the Windows
machine, it's fantastically fast.

So basically, FF is for work purposes. Firebug is unbeatable as a
development tool, and the way it reloads Javascript inside iFrames
(unlike other browsers) means that it does everything needed. Safari,
as mentioned earlier, has some useful development tools built in. Not
as much as Firefox, and it doesn't have the ability of Firebug to
change CSS or HTML on the fly. However, the speed of it ensures that
it sees almost constant use googling things, or just inserting
content.

But. Chrome is brilliant. Even more streamlined then Safari, it
also runs faster. The ability to go to a URL or do a search from the
address bar is great and makes things so much quicker. The only reason
it isn't number 1 is because it doesn't run on a Mac. Odd choice by
Google that.

Developing

Eclipse. The colouring of code makes spotting problems and reading
what things are doing much easier then the bad old days of notepad.
Plus it synchronises with SVN repositories. The only downside is the
problem it has with each project, whereby it can't figure out which
variable to use and stops working for about 20 seconds. Annoying, but
I put up with it because of the other advantages.

Along with WAMP or MAMP, there really isn't anything more you need
then Google :)

Wednesday 9 September 2009

First!

Ah, a shiny new blog.
This 1 (to go with the other 1) is designed to hold all the pearls of wisdom I can pick up while working. I'm sure someone, somewhere will find this useful. If not, well, hopefully I have fun :)