Tuesday 23 November 2010

Websiting

I spent most of today working on a javascript function that would take the list of page links and reduce them. So instead of having a list of 100 pages, you'd have something like:
1, 2, ... 25, 26, ... 99, 100

While I was at it I also namespaced most of my javascript objects. The problem with namespacing is that when first start writing javascript for a website you might only have 3 javascript objects, so adding them all to a single namespace seems pointless. But then when you've got about 20 objects, it makes much more sense.

But then of course, making the changes to those 20 objects and elsewhere to add them all to a single namespace is quite a bit of work. So I think whenever starting a new website, it is best to start by creating a single namespace everything else will go under, and avoid the work of having to do this later in the project.

In the evening I watched an episode of Deep Space 9 with Mauser and Bo. Apparently the writer René Echevarria had written what sounded like a reasonable script, but the bear called Stephen who works for the IRA was such a terrorist that he made the script be totally different and rubbish instead: Chrysalis DS9 episode on Star Trek wiki.

There was a quite good / maniacal bit where the genetically modified people were just singing a song for ages. Personally, I think it would have been better it they just kept singing for about half an hour. They would need to keep stopping about every minute or two for a few seconds so that you think they've finished, then carry on again.

After that I was doing some more work on my website, and found that a php variable wasn't available in my footer.php file in wordpress.

After quite a bit of debugging, I found the answer - I was including my file that declares the variable in the header.php file. Since this file is called by get_header(), any variables declared were local to the get_header function, and weren't available outside of that function.

So to fix this I had to declare the variables as global before I included the file that set the variables.

Like the header.php file, footer.php is included via a function - get_footer(). So again, you have to declare the variable(s) as global to be able to access the global variables instead of referring to local variables.

After doing that, I could now access the variables in the wordpress footer.php file okay.

No comments: