VZ Url extension

March 11, 2009 at 10:09pm.

This entry is about Expression Engine, Programming

38 comments.

Brandon Kelly has done the Expression Engine developer community a great service with the release yesterday of his FieldFrame extension. He has created a framework for the quick development of new fieldtypes (like the XHTML and drop-down types that come with EE). I couldn’t resist experimenting with FieldFrame, and—aside from a few areas that are not yet documented—it is as easy as promised.

I whipped up a Url fieldtype, somewhat similar to Designchuchi’s URL Field Extension, but with the addition of ajax validation. When the user leaves the url field, it will ping the url they entered and display an error message if it doesn’t find a valid webpage there. If the page has moved, it will also alert the user and offer to update to the new location.

VZ Url screenshotPlease note that VZ Url will not prevent the user from saving their weblog entry if if cannot validate the url—it just warns them. This is intentional, perhaps they are linking to a page they have not yet created, or the site they are linking to is currently down but they know the url is correct. I may add this functionality as an option later on.

Prerequisites

You must have the FieldFrame and jQuery for the Control Panel extensions installed and enabled. Your server will also need to have the CURL library enabled for the link checking to work.

Tag

You will generally display the entered url in your templates just like you would any other text field: {vz_url_field_name}. You can also use the optional redirect parameter to immediately redirect visitors to the entered url. You should only use this if you really know what you’re doing…with great power, etc. The syntax for redirects is {vz_url_field_name redirect="yes"}.

Installation

Download and unzip the extension below. Upload the files, following the folder structure in the download. You will need to enable the VZ Url fieldtype in FieldFrame’s extension settings. Then you will need to go back to FieldFrame’s settings & show the settings for VZ Url to set the error message that will be shown if the url is invalid.

That’s it! Now you can use the VZ Url field type anywhere you were previously using a plain text field. Switching from a Text Field to a VZ Url field (or vice-versa) will not affect your data.

Version History

  • Version 2.1.2 Fixed a javascript error that was preventing multiple fields on the same page from validating at the same time.
  • Version 2.1.0 Added the option to only allow local URLs. Removed error message settings interface (edit the language file if you need to change the wording). Heads up: This will probably be the last new version for EE1, aside from bug fixes.
  • Version 2.0.3 Now compatible with SafeCracker.
  • Version 2.0.1 Added redirect parameter that immediately redirects visitors to the field’s url. The inspiration and most of the code for this feature came from Brian Litzinger.
  • Version 2.0.0 EE2 compatibility! Also, error messages are restyled, the “redirect” message can be edited, and most of the code was refactored.
  • Version 1.1.7 Changed handling of redirected url. They are now considered valid as-is, but with the pop-up prompt to update to the final url. Also fixed a bug in checking multiple VZ Url fields when editing an existing entry.
  • Version 1.1.4 Removed hard-coded url to a testing copy of proxy.php that I had mistakenly left in.
  • Version 1.1.3 No longer equates “no url” as “invalid url”.
  • Version 1.1.2 Compatible with PHP < 5.2. Compatible with Multi-Site Manager installations. Slight styling fixes.
  • Version 1.1.1 Checks to make sure it’s even a valid url before trying to ping the remote server.
  • Version 1.1 Completely refactored code. Displays errors—inluding a new message for redirected urls—in a new, prettier, pop-up box. Hopefully also fixed all the bugs mentioned in the comments up to now. Read more in my blog post.
  • Version 1.0.2 Preparation for FieldFrame 1.2—thanks to Brandon Kelly!
  • Version 1.0 Now checks urls as you type, rather than waiting until you move to the next field. Also some aesthtic adjustments.
  • Version 0.9.9 Cleaned up the design, refactored the javascript, and added support for FF Matrix.
  • Version 0.9.8 Moved some code around to simplify things.
  • Version 0.9.7 Update to new API structure in FieldFrame 0.9.5; moved to GitHub.
  • Version 0.9.6 Minor update to take advantage of new features in FieldFrame 0.9.2.
  • Version 0.9.5 Initial public release. May be buggy! Use at your own risk! But please tell me if you do find any bugs and I will do my best to fix them.

Download VZ Url

Comments:

Matt gravatar

Matt on April 10, 2009 at 4:54am#1

Thanks for the great FieldType Eli!

Chuck gravatar

Chuck on July 26, 2009 at 6:31pm#2

I am using VZ URL, but I do not see the +Add Row button.  Is something not setup correctly?

Chuck gravatar

Chuck on July 26, 2009 at 6:47pm#3

Hi Again,  I’m still just beginning with tags and FieldFrame.  Is there a way to have the {options} populate into a table…or if not, perhaps several columns?  Thanks again!

EliVZ gravatar

EliVZ on July 26, 2009 at 9:31pm#4

Chuck: If I understand your questions correctly, you need to read the FF Matrix documentation. The things you are trying to do are part of FF Matrix, no VZ URL. Good luck, and let me know if you have any other trouble!

smartpill gravatar

smartpill on August 2, 2009 at 11:55pm#5

For some reason this link to an MP3 file is being flagged with the red “X” even though the link is obviously valid.

Can Berkol gravatar

Can Berkol on August 24, 2009 at 11:58am#6

This is a life saver. Thank you.

Erwin gravatar

Erwin on August 25, 2009 at 12:27pm#7

Eli, your extension doesn’t seem to work with fieldframe v1.3 anymore. It does give an error if my custom field is empty, but it does not give an error when the syntax isn’t correct.

Tom Davies gravatar

Tom Davies on August 25, 2009 at 12:50pm#8

+1 to Erwin’s bug report - no error is given on FF 1.3.2 if the string entered is not a valid url

Eli Van Zoeren gravatar

Eli Van Zoeren on August 25, 2009 at 1:12pm#9

Hmmmm. I’ll take a look at that bug tonight.

EliVZ gravatar

EliVZ on August 27, 2009 at 2:27am#10

Erwin and/or Tom: Can you try upgrading to FieldFrame 1.3.3? It seems to be working fine for me. If you still don’t get the invalid url warning, please send me an email with details—what urls you are trying, what version of ee & php you are using, Windows or Linux server—and I will try to track this issue down.

Erwin gravatar

Erwin on September 5, 2009 at 2:54pm#11

I’ve changed the code of proxy.php to:

<?php
// Proxy for checking if a remote page exists
// Used by the VZ URL extension

$session = curl_init($_GET[‘path’]);

curl_setopt($session, CURLOPT_HEADER, true);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
curl_setopt ($session, CURLOPT_VERBOSE, false);
curl_setopt($session, CURLOPT_TIMEOUT, 15);

/*
// Request the file
$httpcode = curl_getinfo($session, CURLINFO_HTTP_CODE);
*/
$response = curl_exec($session);


curl_close($session);

if(strlen($response) > 4000){
echo 1;
}

The problem was that i was always getting a 200 header, maybe this is some serverconfiguration. This isn’t the real solution, but it works for me :)

Brent gravatar

Brent on October 4, 2009 at 4:12am#12

Love the fieldtype Eli! Thanks for sharing.

I noticed a small JS error on the Edit page when using your fieldtype on it’s own (outside of FF Matrix)

On line 56 of ff_vz_url.js you might want to check if $.fn.ffMatrix is defined.

Thanks again!

smartpill gravatar

smartpill on October 23, 2009 at 6:10pm#13

I get the red checkmark if I enter a URL without a “www” for instance: http://google.com is considered invalid, but http://www.google.com is valid. I’m using FF 1.3.4 and VZ URL 1.0.2.

Jake Mauer gravatar

Jake Mauer on November 24, 2009 at 2:52am#14

Your current link the the VZ URL download is broken. I appreciate your effort and upkeep of this fieldtype!

Jake Mauer gravatar

Jake Mauer on November 24, 2009 at 3:19am#15

False alarm, it looks like GitHub was to blame. Thanks Eli!

EliVZ gravatar

EliVZ on November 24, 2009 at 3:21am#16

GitHub does that periodically, but since it is otherwise awesome we can forgive it. Glad everything worked itself out.

Your site looks great, by the way!

Florian Schroiff gravatar

Florian Schroiff on November 24, 2009 at 11:38am#17

Weird: I installed the Url extension. Now I can set it as a fieldtype on its own, but I can’t select the fieldtype inside an FF Matrix.

I’m playing with Fieldframe for the first time, so chances are I’m doing something wrong…

Manoj Thomas gravatar

Manoj Thomas on December 4, 2009 at 12:34am#18

The version on github isn’t the latest. When I download it it turns out to only be v1.0.5

Eli Van Zoeren gravatar

Eli Van Zoeren on December 4, 2009 at 4:04am#19

Manoj- How did you download it? The version on GitHub is the newest—1.1.3—so I’m not sure how you got an older copy. Make sure you use the link at the end of my post, if you followed another link from another site, perhaps it was pointing at an old copy, although there was never a 1.0.5 release.

Very strange….

Jason Morehead gravatar

Jason Morehead on December 12, 2009 at 8:01am#20

FWIW, I just downloaded the files from GitHub and when I installed them, and then went to the “Fieldtypes Manager” in my admin area, it says the version is 1.0.5. Additionally, I’m no longer able to use a field that is of the VZ URL type in conditionals—it always returns false.

Eli Van Zoeren gravatar

Eli Van Zoeren on December 13, 2009 at 4:14am#21

Jason- Crap! I just realized that GitHub has been providing an old version through the download button (for how long, I don’t know…sorry everybody). I have filed a support ticket with them to get their cache cleared. I will update this comment when I hear back from them.

[UPDATE] Okay, it’s working properly now.

Jason Morehead gravatar

Jason Morehead on December 14, 2009 at 3:14pm#22

Cool, I’ve been able to upgrade successfully. Thanks.

Joel Bradbury gravatar

Joel Bradbury on January 18, 2010 at 11:11am#23

Hey quick note,

In the ff_vz_url.js (line 76) the path proxy.php is hard coded to be :

“http://www.vsadc.com/siteadmin/extensions/fieldtypes/ff_vz_url/proxy.php?callback=?”

It’s probably just an oversight and nothing malicious, but worth updating the latest version to use a proxy.php under the user’s control, not elsewhere.

EliVZ gravatar

EliVZ on January 18, 2010 at 3:57pm#24

Joel- Wow, I’m an idiot! I put that in when I was testing something, and never took it back out. There’s an updated version on GitHub that uses the correct local copy.

Rob Butz gravatar

Rob Butz on March 12, 2010 at 7:40pm#25

Hey there Eli.

When displaying my custom field, how do I test for the field’s emptiness or non-emptiness with a conditional? I’ve tried doing


{if my_custom_vz_url_field !=”“}
  {my_custom_vz_url_field}
{/if}

When I try this, it always seems to always evaluate as empty, even if it’s not. If I remove the if / if wrapper, the link shows up. :(

Thanks Eli.

EliVZ gravatar

EliVZ on March 13, 2010 at 3:56pm#26

Rob-

Try using just {if my_custom_vz_url_field}.....

Your way should work, as far as I can think, but this is the way I typically do it. If that still doesn’t work, let me know and I will take another look at it.

AJP gravatar

AJP on March 17, 2010 at 4:05pm#27

I’m running into issues with FF 1.4 and no ajax validation gett done.
I get a firebug console error of “$ is not a function” on line 11 ” var $field = $(this);

Thoughts? Thanks!

Paul gravatar

Paul on April 1, 2010 at 6:28pm#28

Is there any way to format the outputed URL differently? Can’t see a way to remove the ‘http://’ protocol or add a custom title attribute?

EliVZ gravatar

EliVZ on April 1, 2010 at 6:34pm#29

Paul-

I’m afraid this is outside the scope of this fieldtype. VZ Url doesn’t do any formatting—from EE’s point of view, it’s no different than a text field where you would type a url. You would need to use a search-and-replace plugin to remove the “http” and probably another field for the custom title, depending on how much control you need over it.

HP gravatar

HP on April 25, 2010 at 11:05pm#30

Upgrade successful, it went without any problem. Thanks for this extension

Yujin gravatar

Yujin on May 12, 2010 at 2:14am#31

Eli, first, thanks for a great fieldtype extensionto use in FF. 

The link checking/verification works when you actually place a new link into the field.  When you reopen the weblog to view existing links, the circular arrow icon in the field just keeps spinning without verifying the link.  These are links that were verified when initially entered.

Should it be doing this?  Wasn’t sure if it is supposed to check existing links.  Seems like it is trying, so just want to make sure.  Thanks for any help.

Brandon gravatar

Brandon on June 19, 2010 at 8:03pm#32

I’ve noticed the same problem as the last commenter - my client have mentioned it several times as well. Any chance we can get a fix for that soon?

Eli Van Zoeren gravatar

Eli Van Zoeren on June 20, 2010 at 3:57pm#33

Brandon- 
Sorry, I resolved that issue via email with Yujin and never posted back to this thread. Have you downloaded the current version from GitHub? That should fix it for you. If it doesn’t, let me know and I’ll see what else I can do.

Steve gravatar

Steve on July 3, 2010 at 2:06am#34

Any news on whether this will be available on EE2.0? Awesome plugin and would hate to lose it.

Thanks!

Eli Van Zoeren gravatar

Eli Van Zoeren on July 3, 2010 at 9:43pm#35

Steve-

An EE2 version of the fieldtype is definitely in the plans, but I haven’t had time to port it yet. I’m hoping to do so in the next month or two, and know that there is a need/desire for it will help give me the incentive to finally get around to it!

vonas gravatar

vonas on January 25, 2012 at 10:19am#36

From fact that point of run over<a >.</a>

BUYDULOXETINE gravatar

BUYDULOXETINE on April 13, 2012 at 7:52pm#37

free cymbalta coupon

Bumpquema gravatar

Bumpquema on October 1, 2012 at 2:42pm#38

<a >銉兂銈儸銉笺儷 </a>

<a >moncler 銉兂銈儸銉笺儷 </a>

<a >銉兂銈儸銉笺儷 绂忓病 </a>

Got something to say?