Archive for the ‘Website’ Category

Dynamic Website

Sunday, December 16th, 2007

The way that I originally created my website was by creating a template in Dreamweaver, and creating a new page based on that template for each new web page.  Dreamweaver automatically updates any page based on a template when that template is saved.  Thus, every page had it’s own coded copy of the header, the sidebar, and the footer.  I figured out that all this does is create a lot of unnecessarily repeated code.  So I decided to try something else.

I created a new sub-domain, dynamic.testing.thetoothpick.com, and deleted everything on it.  I created “index.php,” and started coding the layout.  I wanted to do this entirely by coding (not using Dreamweaver’s layout feature), because it’s a lot easier to get it to do exactly what you want.  I still used Dreamweaver (it’s got a pretty a pretty advanced coding setup), mainly because of the integrated FTP directory synchronization.  Also, I decided to go with div tags instead of tables (they’re just easier to work with, although arguably harder to center).

I put in the first two div tags, for the header and the title, and then the div tag for the main part of the page.  I created a div tag within this for the sidebar (I floated it on the left), then put in the div tag for the actual page content (I floated this on the right).  I made a clearing div tag after this (still in the larger container), and closed the container tag. Then, I made the div tag for the footer.

In properties.css, I made a rule for the div tags in the main column, gave them a width of 740 (not sure why that number, it was the one my table layout used), made both margins “auto” (effectively centering the column on the page). I then made individual rules for each div tag (I used the main column rule as the class, and the individual rule as the id).  I put things like background in each individual rule, and, in the rule for the clearing div, I cleared the floats on both sides.

Clearing the floats in the clearing div made it so that no matter how long the sidebar or main content is, the container would encompass both of them.  However, if the main content was longer than the sidebar, there would be a gap between the end of the sidebar and the footer.  So I made a image that was as wide as the sidebar, one pixel high, and the same color as the sidebar background, and made this the background of the main content div (as well as left aligning it and setting it to repeat on the y-axis).

Now for dynamically getting the page title/content.  I made a directory called “pages,” and made .php files for each page.  In the root folder, I made function.php, and in that a function that compared the $page variable passed to it (which was set in index.php to the value of $_GET['p']) to values stored in an array, which defined every page I had created, and returned true if it matched a value.  I called this in another function, which would include “/pages/$page.php” if $page was a valid page.  I also made another function, that returned the value of $pages[$page] ($pages is the array of defined pages), again, if $page was a valid page.  I also made provisions for if the requested page  isn’t defined.  That way, I could set $title to getTitle($page), echo $title in the title of document and underneath the page header, and simply call get($page) in the main content area.  I also included files for the sidebar and footer, so I could easily update them without changing the whole page.

I tested it out in IE, and it looked perfect (well, exactly like it had before).  So I sent it to my friend.  She mentioned a gap between two of the div tags (where they didn’t meet).  That was when I realized I hadn’t tested it in Firefox (or Opera, for that matter, or Safari).  I looked at the page in Firefox, and, sure enough, there was a pretty noticeable place where the div tags didn’t meet.  In Opera, same thing, but a different place.  I went into the CSS, and put borders around every div tag, just to see where one ended and the next began. I went back, and in both browsers, there were pretty big borders, but no gaps.  So I tried putting borders around just the affected div tags, and the same thing happened.  I made two new CSS files, one for Firefox, and one for Opera, made a border around the top and bottom of them, and changed the color to the color of the rest of the div tags (#006600), and put php if statements around the two statements importing them (if the browser was Firefox, import firefox.css, same for Opera).  I asked my friend too look at it again, and she said it was fine.  I checked in both Firefox and Opera, and it looked fine in both.

So, index.php is now 33 lines, as apposed to 120.  And I only need one copy of every line.  I can also link to other documents with /?p=sites, not /sites.php.

Oh, and by the way, the site described here is now what you see when you go to http://thetoothpick.com.

thetoothpick.com Design Update

Sunday, September 9th, 2007

Did I seriously neglect to post about my design overhaul? Oh well…

 I changed the layout of http://thetoothpick.com/ from the kind of blocky, straight thing it was to… well, kind of like a capsule.  It’s easier to show:

I’m going to experiment a bit with the header (I’ve given up trying to include the desert picture I had before).  I’ve found an image editor for Linux that will let you create/modify images (including adding text), from the command line, and someone’s created a PHP extension for it.  Now, all I’ve got to do is figure out how to install it on my server (I don’t own/control it).  I guess I could just ask IX, but I’m not sure they’d do it. In all honesty, I’d prefer to host the website on my own computer, but that’s more or less out of the question (my SharePoint site is already unbelievably slow. I didn’t post about that either, did I? I’ll get to that later).

I’ll keep changing this from time to time, but it’s gonna look a lot like that for a while.  My change log’s looking unused (yea, I’m keeping one.  And I’ve managed to almost lost it twice…).  If anyone’s got any suggestions, let me know.

School is out!

Wednesday, June 20th, 2007

It is. It doesn’t really feel like it though… Well, kinda does. But whatever.  It is.  Which is why I’ve started playing Rainbow Six Vegas.  Dam that game’s fun…

Fuck. I still haven’t gone back to Deviant Art yet.  I’ve been kinda putting it off… cause there’s going to be so much to do. I’m sure I’ve got tons of stuff to catch up on at WL, if the sarge hasn’t kicked me out yet =/.

Running. Started running again yesterday… Dam I’m out of shape… but it wasn’t as bad as it could have been, I guess.

Cub Scout Day Camp. Incredibly fun. I’m an assistant den chief, so I just sit down and watch the kids being dealt with by some other person who’s running a station or something. Owen (the den chief) just kinda leaves sometimes, so i’ve got to take care of them. 11:45-5… :(

 I might start Drivers Ed at some point.  Soon. I hope. :D.

Anyway, Oljato (scout camp) next week, then free time :D.  Maybe I’ll work on my website a bit more (which, by the way, got a logo), and explore Linux (I’ve got it installed on another machine, and whenever I try to run Firefox, it tells me I’m missing a library that is most defiantly there, with a link to it in multiple bin folders. -_-).  I guess that’s all for now :D.

TheToothpick.com Launches (with new error messages)

Wednesday, June 6th, 2007

I’ve moved everything from my testing site to my main site. I’m basically done editing my page, so there’s no use keeping it on a testing directory. I’ll still use it as my testing site (I use Dreamweaver, which lets you upload things to a separate testing folder).

 

The error messages are… simple. But less simple than before.

 

 

That’s about it for now…

sandbox.thetoothpick.com

Wednesday, June 6th, 2007

By modding the CNAME values in the DNS record for thetoothpick.com, my sandbox site (which is still hosted on my desktop) is now accessible from http://sandbox.thetoothpick.com. which really serves no purpose whatsoever, except to bring it to my domain. Centralization, you know?