Monday 20 January 2014

Adventures in the magical world of php

Since creating a new website on the weekend, I have been making one or 2 changes.

In brief the changes are:
1. Icons at the top of the homepage feed for the rss instead of links, it just looks neater I think
2. I changed the date format at the top of the posts so that the day now comes before the month, I don't want to say whether the English or the American dating convention is the right one, but the English way is definitely the right way.
3. There is now a corndog pictures link on the left hand side.
4. There is a losing time link on the left  hand side, but what does that mean?

The main reason for making changes is because I want to challenge myself, much of the site is now in php, which for those of you uninitiated with web coding, is like writing html, except you try and make it write part of the code itself.

PHP I find really confusing, especially compared to html, html is really simple content and so on, you just learn what the tags are and you position them around your page forever, wouldn't it be great if all programming was like html, the whole world would be geniuses in no time, whereas php is all question marks, semicolons and brackets, miss one out and it is broken.

I first used php when trying to update the old version of my website, I had a links bar on the left hand side which is fine if you've got 2-3 pages, but my collection of pages just kept on growing, I had an unnatural and probably an unfair aversion to using frames, so i was on the lookout for a different way, the best way seemed to be with a php page, where I create a simple php page (ok so a html page with a .php suffix) for the links list and use ?php include to pull the links page in. Magical, instant time saver.

I was so taken with this effect that for the new version I created one page for the top and the left and all just include that and the content is just added to the large box part on the right, not only do I have an easy to update links list, but I could change the banner and the colour scheme just as easily.

Now having the php pages was one thing, I had the structure sorted, but I thought, surely I can manage more than one line of php, right? So I created a news feed using a code I found on the internet, it pulled through my newly combined rss feeds and it was there, I couldn't believe what I had achieved! To be honest, not much, some anonymous person from some dark corner of the internet created that, I would have to do some more to feel that same sense of achievement, it become instantly clear that when echoing text and so on into the page, you simply revert to html, oh how things start to become clear then, i could use my favourite visual organisational tool the table quite easily, just start the table fields in the first echo and close the table off in the last one, with a bit of shuffling I got the date onto the same line as the title and with 1 simple line I was able to restrict the body to 1000 characters, so far so good.

Then I came up with another idea, what if my posts worked out which blog they were from, wouldn't that be great? I found the equivalent code for IF functions online and had it read the link field, 4 times one for each blog and it worked! the largest change I had made yet, I was quickly figuring out this php stuff, I was able to replicate this success on a separate news page, where I could remove the link from the top and put it at the bottom as a 'comments' link, no particular benefit to this, something just told me I wanted a separate page for this, to try and differentiate the 2, they are not limited on the news page.

Now that I felt I was coming to understand php (it was delusion, I was not), I thought I wonder what else comes in rss feeds, ooh, what about flickr? I havge a flickr feed, that would be good - Now don't get me wrong, I do not believe that having a pictures page on my website is any better than just linking directly to the flickr photostream, in fact the rss feed only shows the last 20, so it is far less efficient, but I thought I would have a go.

Then I came across a stumbling block, the pictures themselves were in a media:content tag, this was not what I expected, I tried including it in the same way but it didn't work, it turns out this is a namespace and I found some codes I could use, though they were not the same as what I had, all the items I had were listed in 1 $item array, whereas the code I found was to pull through the item by itself. I decided I didn't want to do this, to do this would be to admit I had learned nothing and that the code I had was somehow wrong, I was sure I could turn the line of code into a bit of an array... I could, it was amazing, the result is here, my pictures page.

It turns out that I am of the genuine belief that people want to read about coding, but without any of the pesky advice telling them how to actually do it.

Sunday 19 January 2014

New year - New website

I have tried to maintain websites before, the main problem I tend to come across is that I just cannot be bothered, then the other day I realised something that spurred me into action.

Recently I registered for a forum, which is something I had not done for quite a while and decided to add an image, I thought, hey I'll just add it to wannacorndog, so I did, I clicked to preview my shiny new post and... "Your hosting account does not support hotlinking".

Ok, so I can't really get indignant, I don't actually pay for hosting, so the restrictions imposed by the host is just something I have to accept, but I don't feel like I'm asking for much, if unlimited images can be uploaded and shared on imageshack, flickr, photobucket and so on, then surely my web host can do the same? If I actually expected to make any money from my website, then I wouldn't mind paying for this service, those banners on the left column of the page would just net me some bonus credit or a few pence off my phone-bill if anyone signed up after clicking them, so already with the bi-annual domain name renewal fee and the time put into maintaining it, it is very much a loss making enterprise.

So yesterday, I packed up my virtual things and registered for a new hosting service, so here we are on fresh new servers at holdonhosting.net - Isn't it nice?

Having moved, I felt like a little change was in order, the first page on wannacorndog.co.uk used to point to a collection of pages, that I had spent quite a while filling in and creating areas creating sections and promising content that never quite came to be, so a while ago, I changed it and pointed straight towards the corndog blog.

Now, I want a website again, but this time I want it to be less work, so I decided that what I would do is basically aggregate my blogs on it, I have started many blogs in my time, so I just needed the essential ones, so I have the corndog blog, which I add corndog pictures to on a very occasional basis, a blog that Isn't about corndogs which is basically another one I created to record the occasional thoughts I have that do not feature corndogs, I recently took my Travel Blog out of long term storage in order to write about holidays to other countries and finally this one, which I started years ago, wrote one post about making corndogs and then forgot about, so it seemed perfectly placed to be used instead as a kind of website news blog.

The majority of the work then was in figuring out how to display the content of an rss feed, I was so pleased when I put the articles into tables, managed to restrict the character count on the list on the homepage and my proudest bit, having it work out which blog it was on. This is obviously easy for some, but I'm relatively new to php.

Now its great, I can update most of it by simply filling in a blog, look for more soon, or not, doesn't matter, just subscribe to the rss feeds if you really want, I wouldn't, I'm not that interesting