Web Development

Display Featured Links Randomly Using PHP

Posted on June 29, 2009. Filed under: Main, Tech Tips, Web Development, Work Links | Tags: , , , , , , |

I had a request to add a "Link of the Day" feature to one of the pages on the Law-related Education pages of the OBA Web site using what we currently have in place.  I’m sure there are widgets out there already that will do this for me, and it may even be built into whatever CMS we deploy next, but I wanted to learn a bit so I decided to implement it on our current site.  I don’t know much about PHP, but I learned to code in VB.NET and C++, so I can learn enough as I go to make things work.

With the help of The Google, I was able to piece together a little bit of code that reads from a CSV file into an array, then randomly displays a link from within that array on each page load, so that a new link is loaded on each visit.

The original code has appeared in several forms across the Internet already, so if it’s yours, please let me know so I can credit you.  I’ve made some slight adjustments to fit my needs.

  1: <?php
  2: function makeClickableLinks($text) {
  4:   $text = eregi_replace('(((f|ht){1}(tp|tps)://)[-a-zA-Z0-9@:%_\+.~#?&//=]+)',
  5:     '\\1', $text);
  6:   $text = eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_\+.~#?&//=]+)',
  7:     '\\1\\2', $text);
  8:   $text = eregi_replace('([_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3})',
  9:     '\\1', $text);
 11: return $text;
 13: } // end function
 16: function displayLink(){
 18: $fp = fopen("your-file.csv", "r");
 19: while (!feof ($fp)) {
 20: $contents[] = explode(",", fgets($fp, 512));
 21: }
 22: fclose ($fp);
 24: do {
 25: 	$x = rand(0, count($contents)-1);
 26: 		} while ($contents[$x] == '0');
 28: // displays link title above clickable URL
 29: echo $contents[$x][0] . "<br />\n" . makeClickableLinks($contents[$x][1]) . "<br />\n";
 31: // displays link title as clickable link
 32: echo '<a href="' . $contents[$x][1] . '" rel="nofollow">' . $contents[$x][0] . '</a>';
 34: } // end function
 36: ?>
 37: <body>
 38: <?php displayLink(); ?>
 39: </body>

Click to view a working sample of this page here.

WordPress Tags: Display,Links,Link,Education,code,Google,Internet,text,Click,Development,adjustments,makeClickableLinks,eregi_replace,displayLink,clickable

Read Full Post | Make a Comment ( 1 so far )

Don’t Forget to Clean Your Code!

Posted on June 17, 2009. Filed under: Main, Microsoft, Tech Tips, Web Development | Tags: , , , , , |

I recently was asked to update a Web page with a rather long list of names, which were provided in a Word document.  I use a combination of Dreamweaver and Expression Web, because they both have good tools for stripping out problematic HTML from Word, but today they weren’t much help.

This particular document had a table (of sorts) built into it, which listed names and cities, but after a good ol’

copy and paste, I found that things didn’t quite line up.  Upon closer review, I found that the “table” was actually made up of tabs and spaces.  While this worked in Word, it made a horrible mess for the Web.  Just doing a copy and paste job created spaces (technically non-breaking spaces — “nbsp”) that seemed like empty space, but actually take up quite a lot.  In fact, these spaces made the page 322kb!  Most of the larger pages on the site were around 20-25kb, so I took another look at things.

In this case, I decided not to go with a table for the little bit of text that could fit in, instead going with the city name in parentheses after the person’s name.  After removing all the nbsp’s from the code, I was able to shrink the page to 32kb – a 90% reduction in page size!  That means the page will load in just over 1 second, instead of over 12 from before.

So, to recap:

  1. Copy and paste doesn’t work as expected with the web, so be prepared to clean up your code a bit.
  2. Check for spaces that don’t belong, particularly the “ ” – they take up more space than just hitting the spacebar does.
  3. Use a tool like Firebug for Firefox, or the built-in tools in several other browsers (IE8, Safari 4, Chrome) to test your page for load times and see how you can improve them.

Windows Live Tags: Code,Word,Dreamweaver,Expression,tools,HTML,spaces,text,reduction,size,Copy,tool,Firebug,Firefox,Safari,Chrome,nbsp

WordPress Tags: Code,Word,Dreamweaver,Expression,tools,HTML,spaces,text,reduction,size,Copy,tool,Firebug,Firefox,Safari,Chrome,nbsp

Read Full Post | Make a Comment ( None so far )

New Day, New Look

Posted on April 10, 2008. Filed under: Main, Web Development |

Well, the day has come!  EstesTech.net is live again with a new look (although, as a web guy, I can’t say it’s going to stay that way long.

Come on by and take a look, and reply in the comments section to let me know what you think.

Read Full Post | Make a Comment ( None so far )

What Browser Do You Use?

Posted on March 25, 2008. Filed under: Main, Microsoft, Tech support, Web Development |

Via TechCrunch

There is a scourge on the Web. It is called Internet Explorer 6. Even though the more recent version of Microsoft’s browser, IE7, has been around for more than two years, IE6 still represents 31 percent of all browsers out there (versus only 22 percent for IE7 and 36.5 percent for Firefox). This upgrade lag is simply unacceptable—to programmers, that is, who find it a real pain to make sure their Web apps work on five different browsers. Not only that, but IE6 supports some non-standard features and functions that are not compatible with other browsers.

I’ve been using and developing for IE7 since the beta version was released and I have to admit, it’s making standards compliance a TON easier, which is why I’m joining SaveTheDevelopers.org in their effort to get users to upgrade their browsers from IE6.  I’m not saying everyone needs to use IE, as I happily use IE7, Firefox and Opera side-by-side, as well as Safari every now and then.  I’m just encouraging everyone to move away from IE6 as your browser.

Won’t you join me in saving the Internet?

Related posts:
Save the Developers! Stop Using Internet Explorer 6

Read Full Post | Make a Comment ( None so far )

Site Updates

Posted on March 7, 2008. Filed under: Main, Web Development |

If you’ve visited the site in the past week, you’ve seen that we’ve been making changes.  One of those is a complete redesign using desktop based software (instead of Microsoft’s online SharePoint based software).  Don’t worry, we haven’t gone anywhere!  We’ll have the new site up soon.

If you’re interested in more info, you can email us at info@estestech.net and we’ll do our best to answer your questions.


Read Full Post | Make a Comment ( None so far )

Now More Contact Options

Posted on January 26, 2008. Filed under: Main, Microsoft, Web Development |

I came across an article through the LiveSide blog, which got me poking around the Live Developer site a bit more.  I learned that now you can include your own little Live Messenger chat window in your web site!  I like the idea of being reachable to not only my clients, but to those of you who are looking for immediate help, so I’ve included this as an option on the Contact Us page of the Estes Tech site.

Now you can email, call, or chat directly with me when I’m online, and I can help answer questions for you as they arise.  Give it a shot!


Insert IMMe Link Plugin – LiveSide – Developer Blog

Windows Live Messenger

Read Full Post | Make a Comment ( None so far )

How do you host?

Posted on June 19, 2007. Filed under: Microsoft, Web Development |

Microsoft has a survey for Web Developers to help them improve they way they work with us.  I recommend taking a few minutes (about 5) to read about it on the Expression Web Team’s blog and take the survey.

Here’s the link to the blog entry talking about the survey:

Hosting and Publishing Survey

Read Full Post | Make a Comment ( None so far )

A List Apart’s Web Design Survey

Posted on April 27, 2007. Filed under: Main, Web Development |

A List Apart Web Design Survey

I’ve always appreciated the openness of the Web, especially when it comes to sharing knowledge.  As I continue to work on new designs and layouts for clients, I’ve found A List Apart (^) to be a great resource.

This year, I took part in their annual Web Design Survey,(^) and I encourage anyone else who’s involved in Web work to share your experiences, as well.  Just click the link or the image above to start.

del.icio.us tags: , ,
Read Full Post | Make a Comment ( None so far )

The Move to Expression Web

Posted on April 23, 2007. Filed under: Main, Microsoft, Web Development |

Well, I’ve moved completely from FrontPage to Expression, and the world is a better place now!

Well, not really, but at least my sites all work right.

Last week, I finally weaned myself off of FPSE (FrontPage Server Extensions) by removing them from my development machine.  I realized that the only reason they were on there is because I could open a web site using http:// and edit it live, even though that’s usually not the best method.

Since Expression Web creates standards-based sites right from the get-go, and it makes learning/using CSS that much easier, it made sense for me to leave FrontPage behind (since I’ve already decided not to use DreamWeaver).  I was still hung up on having FPSE, but didn’t really have a good reason as to why.  After chatting with Cheryl Wise (link) and in the Expression newsgroups (link), and reviewing her Expression site (link), it just made sense to leave them behind, as well.

So I now create sites on my computer first, upload them to the server using FTP, and make any changes to the disk-based site, rather than on the live site.  It takes a few more minutes, but it helps to maintain the integrity of the live sites I maintain.

Now, if I only had some artistic talent…


Read Full Post | Make a Comment ( None so far )

New pages and logos

Posted on April 16, 2007. Filed under: Clients, Main, Web Development |

Hi all, you’ll notice that there’s been a few updates here lately.  That’s because I’ve been pretty busy, and the more I work, the more I update, and that’s a good thing!

The new pic in the header is courtesy of PD Photo.org.  It’s a great shot of the Coronado Bridge between Coronado and San Diego, where I used to live and work.  Such a great place!

I’ve also went with a new WordPress theme, Contempt.  Not in love with the name, but it’s a good, clean presentation.

One of my clients has been busy, with a big new advertising campaign, Too Good to be Through has put all their inventory online.  Along with that, they’ve updated their logo header and site coloring.  The beauty of CSS has really helped out in that area!  You can find out more about their shop at www.toogoodtobethroughonline.com, or you can stop on by if you’re in the Oklahoma City area.


Read Full Post | Make a Comment ( None so far )

« Previous Entries
  • July 2018
    S M T W T F S
    « Jun    
  • Meta

  • Categories

  • delicious tags

  • Blog Stats

    • 10,802 visits

Liked it here?
Why not try sites on the blogroll...