autoprefix urls with http:// for user supplied links in a links page
Posted: 31 January 2008 06:59 AM   [ Ignore ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  317
Joined  04-11-2006

In one site, members can add links to a links page - they supply the url to an external site, the link text and a brief description. The info is held in the fields {f_link_url}, {f_link_text} & {f_link_desc} respectively.

Sometimes users enter the url in the form:

www.goodsite.com

and sometimes in the form

http://www.goodsite.com

If I just use the EE code

<a href="{f_link_url}" title="{f_link_desc}">{title}</a> {f_link_text}

then I have a problem with the first form, as EE generates an internal link to a none existant page, rather than to the true external site :-(

So my question is: Is there a simple way in EE to force to prefix the contents of {f_link_url} with ‘http://’ if needed?

BTW I dont want to use the option in weblog admin to ‘automatically turn urls ..into links’, as this uses the url for the link text, which can look extremely messy when the page is from other CMS’s.

 Signature 

OakenPage website works - doing simple things well

Profile
 
 
Posted: 31 January 2008 07:18 AM   [ Ignore ]   [ # 1 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6579
Joined  04-15-2006

Hmm,

I think you are going to need to use PHP on that or create a plugin to do what you need. On the other hand, where are the users inputting this information. If it is through a Stand-Alone Entry Form or any other place other than the control panel then you could use some javascript regex validation on the field to make sure that they put in the http:// bit. The best Javascript validation routine I have ever come across is Live Validation.

That would work for you.

Hope that helps?

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 31 January 2008 07:21 AM   [ Ignore ]   [ # 2 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  317
Joined  04-11-2006

Hi Mark and thanks for the quick reply

I was afraid that that might be the answer ... sigh

 Signature 

OakenPage website works - doing simple things well

Profile
 
 
Posted: 31 January 2008 07:25 AM   [ Ignore ]   [ # 3 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6579
Joined  04-15-2006

Not the only answer though. I will have more of a think on this one. I just wrote what I did really fast as I am in the middle of recording a radio advert so didn’t have a lot of time!! grin

Will have more of a thought about this later on.

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 31 January 2008 07:31 AM   [ Ignore ]   [ # 4 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  317
Joined  04-11-2006

thanks grin

BTW has your avatar just changed?
the hair looks spikier somehow

 Signature 

OakenPage website works - doing simple things well

Profile
 
 
Posted: 31 January 2008 07:32 AM   [ Ignore ]   [ # 5 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  12417
Joined  04-29-2002

One other option is to check the value of the field for the text string of http:// (first 7 characters) and if they aren’t http:// pre-pend http:// to the field.

Another possible plugin.

I’m not a plugin person - (I’ve only written two of them), but I know I’d use it. Clients frequently don’t put in data correctly.

 Signature 

Quick Reference - EE Trial Options - EE Wiki - Docs for updating a build

Profile
MSG
 
 
Posted: 31 January 2008 07:38 AM   [ Ignore ]   [ # 6 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  317
Joined  04-11-2006

Sadly I’m not a plugin person either.

I had thought about that approach, but thought that I should check first before trying to re-invent the wheel.

BTW It wasn’t just customers entering data wrongly grin I spotted it after entering a new link myself!

 Signature 

OakenPage website works - doing simple things well

Profile
 
 
Posted: 31 January 2008 08:02 AM   [ Ignore ]   [ # 7 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6579
Joined  04-15-2006
Jan_Huygens - 31 January 2008 07:38 AM

BTW It wasn’t just customers entering data wrongly grin I spotted it after entering a new link myself!

Tut tut that will never do!! grin

I will just have to write you a plugin then won’t I? wink

May have to be later on tonight as I am stacked out with work at the moment but will give this a shot for you!

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 31 January 2008 08:08 AM   [ Ignore ]   [ # 8 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  317
Joined  04-11-2006

Brilliant grin

Thats really kind and very much appreciated indeed.

 Signature 

OakenPage website works - doing simple things well

Profile
 
 
Posted: 31 January 2008 08:33 AM   [ Ignore ]   [ # 9 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  12417
Joined  04-29-2002

Mark, in your copious free time, a Complete Beginner’s Guide to Writing Your First Plugin would be a *great thing*.

 Signature 

Quick Reference - EE Trial Options - EE Wiki - Docs for updating a build

Profile
MSG
 
 
Posted: 31 January 2008 09:09 AM   [ Ignore ]   [ # 10 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6579
Joined  04-15-2006

Copious free time? You must be joking!! grin

I do have 25 pairs of hands though. Slight problem as I only have the one brain!!

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 31 January 2008 10:27 AM   [ Ignore ]   [ # 11 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6579
Joined  04-15-2006

Hi Jan,

Just to let you know that I am pretty sure I have something working now. I will upload it tonight once I get back from my in-laws as I need to go and fix a computer!
Will test it out thoroughly as well but I am almost certain it will do what you need it to! grin

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 31 January 2008 11:02 AM   [ Ignore ]   [ # 12 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  317
Joined  04-11-2006

I’m looking forward to trying out your latest lifesaver.

You really are a master of multi-tasking - may your 25 hands never grow less smile

 Signature 

OakenPage website works - doing simple things well

Profile
 
 
Posted: 31 January 2008 01:07 PM   [ Ignore ]   [ # 13 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6579
Joined  04-15-2006

Well the time comes for me to unleash another plugin on the ExpressionEngine world!! grin

Neat Link. I really do need to start thinking up some better names for these things though.

Hope it works for you Jan.

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 31 January 2008 01:45 PM   [ Ignore ]   [ # 14 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  317
Joined  04-11-2006

It does indeed. grin

What more can I say? [cept of course, thanks!!]

 Signature 

OakenPage website works - doing simple things well

Profile
 
 
Posted: 31 January 2008 01:51 PM   [ Ignore ]   [ # 15 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6579
Joined  04-15-2006

No problem. Glad to have been able to help.

New version on that page now has class, rel and id parameters too! grin

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 31 January 2008 10:05 PM   [ Ignore ]   [ # 16 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1735
Joined  03-26-2006
Mark Bowen - 31 January 2008 09:09 AM

I do have 25 pairs of hands though. Slight problem as I only have the one brain!!

That made me laugh.

Just to note: don’t forget the power of well documented fields in the Control Panel. I add instructions to every field in the CP. On a field like you have, I might put:

URL (Link)
Instructions: Enter the whole link here, including ‘http:’//’ (i.e. http://www.site.com)

 Signature 

ryan masuga
—————
Masuga Design | Member, EE Pro Network
My EE Add-Ons | {devot:ee}
Twitter: masuga | masugadesign | devot_ee

Profile
 
 
Posted: 01 February 2008 03:27 AM   [ Ignore ]   [ # 17 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6579
Joined  04-15-2006

Yep a very good point about the field instructions.

The only problem being that clients and users don’t always read what is placed directly in front of them wink

In this instance this kind of plugin comes in really handy as you don’t then have to worry if they have done the job correctly or not.

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 65030 Total Logged-in Users: 28
Total Topics: 82119 Total Anonymous Users: 12
Total Replies: 441331 Total Guests: 163
Total Posts: 523450    
Members ( View Memberlist )
Newest Members:  cfvicdreamNOIRgmonCooperWrightReedsmeenoiYang.JianuoioitsukiNathan Hammondalexcig