URL Field Extension for Expressionengine

2nd June 2008 pesche Expressionengine [29] Comments Add your own

Blog Headline Image

Not so long after moving our old website to Expressionengine during the relaunch on May 1st, the big brain engineers at Designchuchi came up with their first EE extension. Fresh from our coding factory comes the URL field extension for EE. Read up on what it does and how you install it.

Download URL Field Extension 1.0.5

Overview

After reading this post over on the Expressionengine forums we decided to give this a try! The idea was to create a custom field to facilitate the entering of external links in weblog posts.

The features of this extension are very simple and straight forward. You can add a custom weblog field with type "URL Field". This field is being displayed on the edit entry form as a textfield with a small icon on the right-hand side. Clicking on this small icon first checks if the URL is empty or if the http:// protocol is missing and triggers a javascript error in that case. Furthermore, if the URL format is valid, it opens a new window with the entered URL so that editors can double-check it before posting.

image

image

image

The extension has now officially been accepted by the Expressionengine development team and featured in the EE extension repository.

Installation

  1. Download URL Field Extension
  2. Upack the archive contents to your Desktop or to a location of your choice on your hard-drive
  3. Copy the extensions/ext.dc_url_field.php file to your /system/extensions directory
  4. Copy the language/english/lang.dc_url_field.php file to your /system/language/english directory
  5. Copy the images/icons/link_go.png file to your images /images/icons directory (you will probably have to create the icons directory).

Activation & Settings

This extension does not have any special activation requirements. Follow these steps to activate URL Field in your EE installation:

  1. Log in to your EE control panel
  2. Go to System Administration > Utilities > Extensions Manager and enable extensions if not enabled already
  3. Enable URL Field extension

Since version 1.0.1 you can use two settings for your URL Field extension:

  1. URL Field Width: sets the width of the field on the publish page. Valid values are either px or %, default value is 300px
  2. Path to Icon: path to the small icon shown on the side of the URL field, has to be relative to your EE installation, default value is /images/icons/link_go.png. You can specify any custom icon you want here.

Feedback

This extension has been tested to work with Expressionengine 1.6.3 and should be compatible with EE 1.4.2 or greater and most modern browsers. If you find a bug or have another feature proposal for this, post a comment about it here and we will be more than glad to fix or consider it.

Changelog

1.0.0

  • Initial release

1.0.1

  • Added settings for text-field width.
  • Added settings for custom icon.

1.0.2

  • Code cleanup.

1.0.3

  • Fixed default icon path bug.
  • Performance optimization, only one database call for all URL Fields. This probably won't have any big impact on the usual EE installation, but in installation where we have many (and we mean many) URL Fields, there should be a performance benefit.

1.0.4

  • Added a simple Regex validator instead of just checking the http:// at the begining of an URL.
  • Fixed bug that was introduced with EE 1.6.5 where custom fields with formatting set to NULL would have 'XHTML' formatting by default. Fixed this by enabling the formatting menu when creating this custom URL field.

1.0.5

Comments

1 June 15, 2008 Clemens

Seems you’re lucky - GeSHify still hasn’t made the cut into the EE extension repository.
I’ve been told it’s still sitting in the developers’ „action required” mailbox - not sure whether they will ever review it :(

Clemens's gravatar

2 June 26, 2008 Ian Beck

Hey there,

I’m having trouble with this extension; when I output the field in my templates the URL is automatically being wrapped in an a tag.  This is problematic because my client wants the link to open in a new window; is there any way to turn off the auto-formatting?  I took a look at the source and the database, but couldn’t find anywhere that the field was getting formatted; my best guess is it’s being processed by the Auto-XHTML option, but there’s no way to turn this off.

Thanks!

Ian Beck's gravatar

3 June 26, 2008 pesche

Hi
It’s a weblog setting - you have to set the property Automatically turn URLs and email addresses into links? to no. Refer to the weblog documentation for further information.
Hope this helps, let us know if it does not.

pesche's gravatar

4 June 26, 2008 Ian Beck

Ah ha!  Thank you, that was exactly the problem!  Someday I hope to be familiar with all the many configuration options (and where they’re stored), but obviously today is not that day.

Ian Beck's gravatar

5 July 23, 2008 Emily

Thanks for this extension. I’ve found that it won’t accept a very long URL that I’m trying to put in because it is more than 128 char.  Is there a way of of setting a higher limit like 255 characters?

P.S this website is very pretty!

Emily's gravatar

6 October 28, 2008 James

one question/bug/feature request… it seems that it only validates the field when you click the little icon. I was assuming that it would check it on a submission. I can’t assume that my users will actually remember to push the link button every time. I want to be sure they have a correctly formed url even if they don’t remember to push the icon button. Also, I noticed that it doesn’t see https:// as a valid url link.

James's gravatar

7 October 30, 2008 Richard

This is a great extension, thanks for all the work.

I think 1.6.5 introduces a bug…setting weblog prefs to “automatically turn URLs and email addresses into links: no” has no effect on the URL field. Text from that field seems to be always run through the XHTML settings (the link text is always output as “<p>http://link-lext.com</p>)

Richard's gravatar

8 October 31, 2008 Rob Q

Can you check compatibility with the latest version of EE 1.6.5 as I found a recent issue with paragraph tags now being inserted around the URL when using this extension and the recent EE version update noted that there were some typography changes and I wonder if the this is causing the additional paragraphs to the link URLs.

Rob Q's gravatar

9 October 31, 2008 pesche

Updated to version 1.0.4 which fixed the xhtml bug as well as the https:// issue. In order to change the formatting of your existing URL fields, you need to navigate to “Admin >  Weblog Administration >  Custom Weblog Fields” and do the following two steps for each of your URL fields:

1. Change “Default Text Formatting for This Field” to something else than ‘none’, for example ‘xhtml’, don’t forget to check Update all existing weblog entries with your new formatting choice? and hit “Update”

2. Repeat the first step but with formatting set to ‘none’.

All you existing fields should render fine now.

pesche's gravatar

10 October 31, 2008 Rob Q

Thanks for the speedy fix!

Rob Q's gravatar

11 November 06, 2008 Rob Q

Not sure why but the fix stopped working so that a P tag is now added again as formatting for the URL field. It was working. I added an new extension or two and then it stopped working. I disabled any new extensions and still not working.

Rob Q's gravatar

12 November 06, 2008 pesche

Hi Rob

Is the formatting your URL field set to none? Have you tried resetting it to something else, updating all your URL fields and the setting it back to none and updating them?

pesche's gravatar

13 November 06, 2008 Timothy Kelty

So as far as the formatting issue, did you do anything but change:
“formatting_block” => “block”,
“formatting_unavailable” => “none”,
??

I’m trying to fix the same issue on LG File/Image Manager, and I’ve set that so the dropdown displays, but things are still getting published as NULL. Any ideas?

Timothy Kelty's gravatar

14 November 06, 2008 pesche

Hi Timothy

No, that’s the only change needed. With this, the formatting block is being displayed and values from there are being passed to the database upon field creation.

pesche's gravatar

15 November 06, 2008 Rob Q

Yes, I changed the formatting from none back to br and checked the box to apply to all entries. Then I changed the formatting back to none and check the box to apply changes to all the entries. That ensured that all past entries have been updated and no longer have the p tag however new entries submitted still have the p tag around them? I’m not sure how to combat that. If you want access to the site / control panel - you can take a look if you want.

Rob Q's gravatar

16 November 06, 2008 Timothy Kelty

Yeah, I can reset past ones like you said…but new entries are still getting formatting set to NULL in the DB (even though ‘none’ is selected in the dropdown)

Timothy Kelty's gravatar

17 November 06, 2008 pesche

Yes, I just rechecked it and it seems that new entries are being set to NULL.

Will have to dig in deeper on this one, probably one solution would be to set the formatting explicitly with a separate hook, but I’ll try to find out why it’s not being set in the first place when it should be.

pesche's gravatar

18 November 06, 2008 James

An easy/temporary workaround that I am using is to just use the EE Typography plugin.
http://expressionengine.com/downloads/details/ee_typography/

Just set the formatting to none.
{exp:ee_typography formatting=“none”}

James's gravatar

19 November 06, 2008 Timothy Kelty

Thanks, let me know what you find.

From LG Image/File manager, the only line I see even setting the formatting is this:

// automatically make this field have no formatting
$js.= “\ndocument.field_form.field_fmt.selectedIndex = 0;\n”;

I saw you have that same line in dc_url_field too…
I tried commenting that out, but it still registered as NULL.

Timothy Kelty's gravatar

20 November 08, 2008 wizs

I upgraded to EE 1.6.5 the other day and didn’t realise that any URLs I add started getting <p> tags on them. I uploaded the new version of URL Field and now I get this on all of my site!

“Error

Unable to load the following extension file:

ext.entry_rating_ext.php”

I tried uploading the old version and this still happens!

Please help!

wizs's gravatar

21 November 08, 2008 pesche

Hi Wizs

We’ve never heard of this problem, it seems like a problem with another extension. Could you please get back to me through our contact form and send me your contact data so that we can sort this problem out together.

pesche's gravatar

22 November 08, 2008 pesche

There’s a quick fix for the formatting problem as posted here by James already, just use the EE typography plugin until we come up with a solution for this problem

http://expressionengine.com/forums/viewthread/96291

pesche's gravatar

23 November 10, 2008 Wizs

Hello,

Just wanted to report that my problem posted on November 08, 2008 was an issue with another extension as you said. It was not uninstalled correctly or something like that.

The URL Field works now on 1.6.5 but I still have to turn XHTML on and then off again each time I post a link. Because I run a directory with many links, this becomes quite irritating. Would love to hear about a fix ASAP. Great works guys!

Wizs's gravatar

24 November 12, 2008 pesche

We’ve just posted a new version. The problem should be fixed in 1.0.5, please test and report back if the problem still persists.

pesche's gravatar

25 November 12, 2008 Rob Q.

Looks like it is working for me just fine. Thanks again for the fix!! smile

Rob Q.'s gravatar

26 November 14, 2008 wizs

Working fine now. Thanks so much, this extension is really important to me!

wizs's gravatar

27 November 19, 2008 James

This may or may not be intentional… but both of the following evaluate to true:
http://apple
http://www.apple

I can’t think of a case where this should evaluate to being true. You might want to modify your regular expression to detect for this as well. (of course I may just be dense here!)

James's gravatar

28 February 11, 2009 Kevin

I’m getting an “Error on Page” message in the status bar in IE7. The error says that we have an invalid argument on Line 2353 of the Control Panel Publish page.

Works fine in Firefox.

Perhaps there’s something I’m missing.

Kevin's gravatar

29 September 06, 2009 hcabbos

Hi. I’ve not installed this yet but I’m wondering if this extension allows inserting multiple URIs like Mark Houts’ File extention does. That way we don’t have to create multiple custom fields. That would be sweet.

hcabbos's gravatar

Add Your Comment

Personal Information




Comment *

Settings & Anti-Spam

Remember my personal information

Notify me of follow-up comments?


Related Entries

DC Template Manager

12 months ago

ExpressionEngine offers the possibility to save templates from the database as files. The biggest advantage…

DC FreeForm GeoIP Extension

1 year, 4 months ago

Fresh from the coding factory comes a new, handy extension. Ever wondered where a visitor…

DC Required Category Extension

1 year, 9 months ago

Oops we did it again! Once stared, you might think you cannot stop it—only one…

From Our Journal

DC Template Manager

12 Months, 1 Week ago.

ExpressionEngine offers the possibility to save templates from the database as files. The biggest advantage of this approach is being able to…

DC Feedback Boxes

1 Year and 5 Months ago.

Most website today are interactive – transfer of information is not only one-way but two-way. User are interacting with content: adding, editing…

DC FreeForm GeoIP Extension

1 Year and 5 Months ago.

Fresh from the coding factory comes a new, handy extension. Ever wondered where a visitor who just filled out a FreeForm on…

View the entire journal