Categories

Recent Articles

DOM Trick: de-thumb an image URL

When ExpressionEngine auto-creates a thumbnail image, it gives the option for creating the markup to display the full size image in a new, pop-up window or in a blank window.  If you’re like me, those options aren’t optimal.  So I put together a handy 4-line Javascript DOM trick to give me other choices.

Read on
 

Resource: Findable Websites

There’s many books and resources available on designing client- and server-side web sites, but few which focus on the practical methods of creating web sites that users can find.  This is one worth mentioning.

Read on
 

Converting URL to clickable link

Using a regex routine, we can find instances of URLs in a block of text and wrap them in <a> elements.

Read on
 

One Pixel Rounded Corners

An interesting technique is popping up—1-pixel rounded corners.

Read on
 

Creating a Great Web Site

There’s much to consider when creating a web site.  Audience, interface, design, and content are among the key things which need to be planned for.

Read on
 

Converting URL to clickable link

Using a regex routine, we can find instances of URLs in a block of text and wrap them in <a> elements.

There’s often a need to do some sort of conversion within a chunk of text.  Sometimes simple string methods work fine.  Other times we need to look to more powerful means.  At these times, we pull out the regex docs and go to work.

I had such a need recent.

In the blog here, I use the Twitter Timeline plugin written by Derek Jones to import and display Tweets.  For some reason, Derek didn’t handle the conversion of URLs to links.  This is an omission, IMO, as all major Twitter widgets available have this feature.

Adding the conversion regex

At approximately line 265, just after the block which changes for “status_relative_date”, add the following:

if ($var_key == 'text')
    
{
        $chunk 
$this->statuses[$key]['text'];
        
/* This is the regex goodness.  */
        
$str ereg_replace("[[:alpha:]]+://[^<>[:space:]]+
                 [[:alnum:]/]"
,"<a href=\"\\0\">\\0</a>"$chunk);
        
/* *********** */
        
$tagdata $TMPL->swap_var_single($var_key$str$tagdata);
    
}

This pulls out the “text” portion of the data received from Twitter.  It then looks through it for any URLs and wraps the URL in an <a> element.

05/04 at 07:08 AM

Comments

  No one's commented yet. Add yours!

Add Comment

Name:

Email:

Location:

URL:

Remember my personal information

Notify me of follow-up comments?

© 2002-2008 | carvingCode ™ | carving unique nooks in the web ™ | simple, but not simpler ™