Jump to content

Quick weekly update (31 Aug 2018)


ryan
 Share

Recommended Posts

This week flew by too fast. I did some work on the core, but mostly had to focus on some end-of-the-month client work deadlines, in ProcessWire-powered projects. As a result, I don't have enough core updates to warrant a version bump on the dev branch this week, so putting a quick update here rather than a blog post. ProcessWire 3.0.112 should be ready by this time next week. 

One of my clients recently requested a URL field that intermittently verifies itself—to make sure that the URL is still returning a 200 success, and not a 404 error, or some other error code. Their site has thousands of external URLs (more than they can check manually), and they want some way to avoid showing links for URLs that are no longer working. I thought a self-healing URL field sounded like a cool idea, so put a little work into that this week, and will likely finish it up next week. 

The module is called FieldtypeVerifiedURL and it extends the regular FieldtypeURL field, except that in its configuration you can specify how often you want it to verify that the URL is still valid. It also performs the verification whenever the value changes. It uses WireHttp to obtain and store the response code with the field, whether a 2xx (success), 3xx (redirect) or 4xx (error) code. So if you wanted to, you could filter the pages with this URL field by response code (like to find all those returning 404s for instance).  It can optionally save the <title> tag found at the URL for you as well. In our case, we will be configuring it to check that URLs are valid once a week, and this is something that it will do in the background automatically. 

When a URL is found to be returning an error code (like a 404), the output of the field can be optionally configured to return an empty value rather than the URL (when output formatting is on). I'm not anywhere near finished with this one, but if this sounds useful to you, stay tuned for more on this soon. Have a great weekend! 

  • Like 23
Link to comment
Share on other sites

a URL field that intermittently verifies itself sounds like something I would really like (for external links/URLs).

Right now - with external URLs in mind - I think of a list of URLs that show the status codes of all links/URLs similar to Jumplinks module does for redirects. Would this be possible?

Link to comment
Share on other sites

I could use a field like this. I have a directory of local businesses and non-profit organisations, but sometimes their websites change or they go out of business, so it would be really handy to be able to run an automated script that can either hide or un-publish any listings that don't have a valid address. That would save on manually checking every one on a periodic basis to make sure they still exist. Of course I'd probably still double check manually any that get deactivated before removing them, but it would make the process a lot more efficient.

  • Like 1
Link to comment
Share on other sites

I would have multiple uses for this type of URL field for sure!

At the moment I use @teppo's unreleased ProcessLinkChecker, which is awesome.

I think the key thing would be that in addition to returning an empty value I think it also needs a way to log and also report (maybe via email or other options) broken links so that we don't need to monitor its findings.

  • Like 8
Link to comment
Share on other sites

@ryan

Another thought - I quite like using @wumbo's FieldtypeAssistedURL (https://processwire.com/talk/topic/10530-module-fieldtypeassistedurl/) - or more accurately, my fork of it: https://github.com/adrianbj/processwire-fieldtype-assisted-url/commits/master which adds support for storing local pages as ID, not URL.

I would hate to have to choose between your new URL field as this one. I wonder if you'd consider adding the functionality of the assisted url field to your new one?

  • Like 4
Link to comment
Share on other sites

  • 3 months later...

I came to the same question as @adrian: The FieldtypeVerifiedURL is nice, but without any assist not quite comfy for our editors. How can a combination of FieldtypeVerifiedURL and FieldtypeAssistedURL achieved?

Edit: I'll open a Thread on this in the Profields forum.

Edited by spackmat
Opened a new thread for that particular question.
  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...