@dangayle

PHP Code: Cite your photo sources!

After working on a site that uses images from a variety of different sources, I felt that it was appropriate to cite the sources. (I do come from a newspaper background, so…)

So, what was the best way to do it?

Since the image is being hotlinked from another source, I could do a string search of the domain, then display the appropriate link. Easy enough, right?

It’s not so easy, since you have to search for a variety of sources, then know the link to display. That’s where a PHP array comes in handy.

Here’s the example:

Code Example

<?php
//Creates link to image source for creative attribution
$photoSource = array(
        'wikimedia'=> '<a href="http://commons.wikimedia.org/" rel="nofollow external">Wikimedia Commons</a>',
        'flickr'=> '<a href="http://www.flickr.com" rel="nofollow external">Flickr</a>',
        'picasa'=> '<a href="http://picasaweb.google.com/" rel="nofollow external">Picasa</a>',
   );
foreach ($photoSource as $photoSource_origin => $photoSource_link) {
if (stristr($imagePath,$photoSource_origin)) { ?>
   <p class="image_source">Image courtesy of < ?php echo $photoSource_link; ?></p>
<?php break; }
}?>

Code Explained

You create your array of possible sources, the example here uses Wikimedia Commons, Flickr, and Picasa as examples.

The foreach ($photoSource as $photoSource_origin =&gt; $photoSource_link) loop associates each photo source with its corresponding link. The if (stristr($imagePath,$photoSource_origin)) searches the $imagePath variable, which is the variable that contains the link to the photo, for the terms listed as $photoSource, and if found, then display’s the found search term’s associated link, the $photoSource_link.

The break then stops the loop after a solution is found.

Cool solution huh?

PHP Programming

I know this makes me a real nerd, but I’m starting to almost understand a little about web programming using PHP. (I know, sad id’nit?)

I started out learning but customizing my WordPress blog, this blog, which of course is written in PHP. As I got into it, I started learning how bits and pieces started coming together. (Forget PHP, creating this blog is a large part of where I learned HTML to begin with!)

Now with some of the stuff I do at work, I use basic PHP a lot more. Stuff like if.. else.. conditional statements, basic loops, server side includes, things of that nature. If you have no idea what any of that means, don’t worry, even I didn’t a while back. I’m still learning how arrays work, how sql queries work, cookies, etc. More intermediary concepts.

I’m reading a lot, and learning a lot about how things work on the web. With that comes some obligations, I feel, to help others. That is why I’m going to start writing some basic PHP tutorials to show how the basics work. Keep an eye out for the first tutorials soon!

In the meantime…

Until I get started writing tutorials about PHP, I highly recommend that you get the book PHP Solutions from Friends of Ed. Great book!

New year, New design

So it’s the end of 2007. Huzzah! The Seahawks are in the playoffs again. I’m working, if only temporarily, at the Seattle Times, and things are looking good.

My friend Jonathan sat down with me to work on a new budget to help me reach my financial goals, so starting Jan 1 I’ll have to start being more fiscally responsible. Eh.

In any case, it’s time to roll out a new design for the ol’ webpage.  Looks like I spoke too soon. Serious CSS errors have been found! I was looking over at wpdesigner’s website (I actually wrote a few articles for him a few months back) and I came across a nice new tutorial that he had put together. It’s called How to Code a WordPress Theme, and it is much better than his former tutorials.

I followed it all the way through during a sleepless night, and what you behold now is the results. Pretty snazzy, eh? I customized it quite a bit, although you can still see the remnants of his Wrath wordpress theme that he used in his tutorial.
new theme screenshot
As you can see from the screenshot, it actually started as a theme I wanted to design for our website Geek-vs-Life.com, but I ran into some difficulties along the way. It works great for my needs though. I’ll be continually tweaking it as I go along,  (It’s busted!) and eventually I guess I should release it, if Small Potato is cool with it. We’ll see.

<h5>editt</h5>

Serious stinking css errors have delayed the emergence of my new theme. Drats!

New job writing for Wpdesigner.com

EDIT—07/02/07
I resigned this position because I’ve decided to finish school this summer if possible. That means, unfortunately, that I won’t have the time or resources to devote to writing tutorials. Bummer!

I just got a new job writing tutorials for wpdesigner.com, and I’m excited! Small Potato writes the best tutorials on WordPress blog theming, so I’m glad to be a part of his growing WP theme development site.

I’m not really a coder, so it’s a good experience for me to learn a bit more about PHP, XHTML, CSS and all of those other mind-boggling acronyms. (Did you know that PHP stands for “PHP Hypertext Pre-processor”? THE ACRONYM IS PART OF THE NAME THAT IS ACRONYM’D!!!!!)

What I hope to bring to the table is more of a designer’s viewpoint, and also a bit of humor. The humor part will come as I get more into things, but rest assured, that’s to come.

Also, I was just put in charge of design for the tech/geek culture blog that I write for at geek-vs-life.com. I’ve been a putz and haven’t gotten a chance to do anything for it yet, but big plans are in the works.

WordPress Theming Tutorials

I can’t describe how helpful the tutorials at wpdesigner.com have been. Absolutely fabulous. If you’re interested in a basic lesson in PHP and CSS coding for theming your own blog, this is THE PLACE to check it out.

Yahoo! Hosting and Email

I’ve had a Yahoo account for about 10 years now, and I’ve stuck with them through thick and thin. So when it came time for me to start up my own web page to host a photo gallery, I decided to stick with good old Yahoo!

But the times, they are a changing.

As good and as cool as Yahoo is, it is limited by the fact that it has approximately 8.6 billion users. What that equates to is that they don’t trust no one. And that includes YOU, the faithful Yahoo Plus! account owner/Geocities Plus! account owner/Web Hosting owner.

I suppose it is great for those who are looking to set up a simple blog, or to just host photos and such, but what gets me is that I’ve had the feeling that I’m being sucked into a deep crevasse, and the only one with the rope is a man named Yahoo! and he’s gonna hafta charge ya for the service of pulling you out.

So 10 years its been. Dear friend Yahoo? I knew him well.

Geek vs Life Anti-Pixel Badge

Show some respect! Here’s a badge for you peoples to be using to show your allegiance to the G-V-L. Use it wisely, for fear that it may fall into the hands of the un-believers.

Recent tweets

Pages