Jump to content
tpr

Module(tte): InputfieldURLChecker

Recommended Posts

InputfieldURLChecker

This is a tiny module to add a URL check button to InputfieldURL. It's live, meaning that it opens what you just typed in, and visible only if the field is non-empty. It's as unobtrusive as can :)

Modules directory

GitHub

It would be the best if something similar would be built-in to PW.

post-3156-0-39566700-1445099748_thumb.gi

There will be probably some tweaks and settings in the future. Suggestions welcome (even for module name).

Edited by tpr
  • Like 10

Share this post


Link to post
Share on other sites

v0.7 is ready. Download link in the first post.

Configuration

post-3156-0-44779500-1445162194_thumb.pn

Changelog

  • fixed link height when URL field is under admin tab (works with ajax-loaded tabs)
  • fixed link height when first tab didn't have any URL field
  • namespaced JS
  • new option: ctrl+shift+click and ctrl+shift+enter modes
  • new option: force http prefix
  • new option: limit module to list of enabled fields

What I plan to add in the future is opening links in a lightbox, and perhaps allowing all 3 modes to be used at the same time. But I think I'll do these only if there's a demand.

  • Like 2

Share this post


Link to post
Share on other sites

Very nice! I don't think you can call it modulette anymore :)

Share this post


Link to post
Share on other sites

It's still a modulette compared to other heavyweight modules :)

The first post contains the link to the GitHub page (v0.8). There was a small code optimization but otherwise it's the same as v0.7.

  • Like 1

Share this post


Link to post
Share on other sites

Hi,

a very useful Modul(ette). :)

Primarily, it is not the "amount" of code what tells about the "weight" of a module. :lol:

------

BTW, when having a look at Github, I spotted DIRECTORY_SEPARATOR in URLs for script and style loading. Shouldn't it be a simple / (slash) instead?

  • Like 1

Share this post


Link to post
Share on other sites

Thanks! DIRECTORY_SEPARATOR was indeed unnecessary, I guess it was a victim of a copy-paste operation :)

Unfortunately there were other bugs to fix. Just realized there are ajax-loaded FIELDS too and not only tabs. Now these are covered too (v0.85).

Positioning of the links was improved too, and fixed the issue when the field had description or notes.

Later I'll add enabled_templates function to make it more versatile, plus make field value clickable if the field is set to "closed + locked".

If I knew there are so many field options to take into account I probably won't start this module :)

  • Like 2

Share this post


Link to post
Share on other sites

v0.9 is up:

  • new option: enabled templates
  • linkify locked field:

post-3156-0-67391400-1445258920_thumb.pn

  • Like 1

Share this post


Link to post
Share on other sites

I was about to ask help here but finally solved things on my own (and looking into other modules).

v0.92 allows using the module on all admin pages. So far it was only added to pages where ProcessPageEdit could hook to, so for example now it is available on other modules's settings pages, or the new module install screen:

InputfieldURLChecker.gif

New (default) option was added: button-left - this is handier because the button is not on the far-right end of the input.

Also the appearance was changed a bit: colored arrow appears only on hover, otherwise remains gray. The button itself is visible all the time, even if the field is empty.

The height of the button was also fixed by adding a dummy url field on start, just to measure its height (and then it's removed). Other measurements were unfortunately buggy.

I'm still looking for a better module name, though I kinda like the abbreviation "TUF", which is used heavily in the JS for naming.

Locked fields got an underline on hover, just to make them more usable.

  • Like 2

Share this post


Link to post
Share on other sites

Not exactly the one I'm after, but thanks :) Keeping the first characters is a good idea, I'll go on that route :)

  • Like 1

Share this post


Link to post
Share on other sites

Okay, settled with "InputfieldURLChecker" as the module name as I found no better one.

In the last few days the module got some major updates:

  • allow button and hotkey modes to be used together
  • asmSelect fields for enabled fields/templates
  • add "placeholder" to asmSelect fields
  • make strings translatable (with __FILE__ textdomain)
  • JS optimizations/fixes

Check the github repo for the details - the options page screenshot shows most of them.

  • Like 4

Share this post


Link to post
Share on other sites

Great!

Please, can you add it to the modules directory too?

It's done in less then 2 minutes, as you have it in a github repo. :)

  • Like 1

Share this post


Link to post
Share on other sites

I'm experimenting with loading the URL in an iframe, sliding in from the right side of the browser window. It works in most cases but fails if the target site's X-Frame-Options is set to SAMEORIGIN, like here on this forum. Unfortunately this is something that cannot be check on the client side. However, I will keep this feature with a note in the readme.

post-3156-0-85631800-1445866999_thumb.gi

Share this post


Link to post
Share on other sites

I'm not having any luck getting this to work... no arrow is shown;

I'm on Mac, Firefox, Chrome, but no luck;

templates and fields all setup....

no js errors..

Any idea what might be the cause, or how to troubleshoot?

TIA

Share this post


Link to post
Share on other sites

I just installed from the module directory (entered the classname "InputfieldURLChecker") and worked fine.

I'm on Win but I don't think that could be an issue. What FF/Chrome versions are you using?

I guess you tried it on az URL type field and not on a regular InputfieldText.

In the module settings, have you added anything to the "Enabled templates" and "Enabled fields" area? If so, the module will be active only in those templates/fields, and unavailable elsewhere.

Also make sure the Mode is set to "Button" and not hotkey.

On the admin page where you expect the button to appear, check the page source if it contains "IUC"  within a script tag in the head.

Share this post


Link to post
Share on other sites

hey tpr - thanks and also let me thank you for this module, it looks great, and you have put a lot of work into it - it will be really handy for this project i'm working on where we need to check that links to external sites are working/correct!

So i checked everything and troubleshot it to where i have narrowed down the issue to the field restriction - if that is set, then it doesn't work; setting the template restriction works... being that i don't really need to restrict by field, i'm all good, but i can further assist with this issue if you need more info.

thanks again!

  • Like 1

Share this post


Link to post
Share on other sites

Thanks, version 1.0.5 is up on GitHub with the fix.

  • Like 2

Share this post


Link to post
Share on other sites

I will rewrite half of the module to take advantage of InputfieldUrl::render, which would make things simpler. Now JavaScript makes all the heavyweight stuff which works, but it's too clunky here and there.

  • Like 1

Share this post


Link to post
Share on other sites

Thanks, version 1.0.5 is up on GitHub with the fix.

great - thanks! Checked it and it's all working now...

Also looking forward to the next version!

Share this post


Link to post
Share on other sites

Just committed v1.1.0 to the dev branch at GitHub:

https://github.com/rolandtoth/InputfieldURLChecker/tree/dev

This is 99% the same in functionality but under the hood it uses InputfieldURL::render and InputfieldURL::renderValue.

The only new feature is that locked field urls now respect the module setting "Target", so clicking on them may open in an iframe if setting so.

Locked url fields with description or notes was linkified incorrectly in the previous (JS-only) version, as all the field contents were wrapped in a link, not only the url. Now it's handled beautifully with the renderValue hook.

Using backend hooks made it much simpler and reliable to deal with template/field restrictions, and probably there will be more benefits in further developments.

  • Like 4

Share this post


Link to post
Share on other sites

Is there a way to specify array in field name? I have this in getDefaultData:

static public function getDefaultData() {
        return array(
            'InputfieldURLChecker'         => array(
                'IUC_mode'              => array(
                    'button'
                ),
                'IUC_button_position'   => 'button-left',
                'IUC_target'            => 'new-window',
                'IUC_force_http'        => 1,
                'IUC_enabled_templates' => array(),
                'IUC_enabled_fields'    => array()
            )
	)
}

Now if I make a  field and set its name to 'IUC_mode' and save the module, the $data in getModuleConfigInputfields($data) will NOT have 'IUC_mode' under 'InputfieldURLChecker' (but a flat array).

I have tried this, but no joy:

$f = wire('modules')->get('InputfieldCheckboxes');
$f->name = 'InputfieldURLChecker["IUC_mode"]';
...

 

Share this post


Link to post
Share on other sites

Hi @tpr.

Thanks for the module.

I have spent some time to understand why the module doesn't work and the issue is that only ProcessPageEdit and ProcessProfile processes are allowed.

But I have several process modules that handle page edit of custom page types.  It would be great if we could control this option in the module config.

There is $modules->findByPrefix("), so maybe you can provide such options with ASM select by $modules->findByPrefix("Process");

Thanks. 

Share this post


Link to post
Share on other sites

Thanks. Are you using AdminOnSteroids? Because this module is not updated for a while since I added it to AOS.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By gebeer
      I am happy to present my new fieldtype FieldtypeImageFromPage. It is made up of 2 modules:
      Fieldtype Image Reference From Another Page is a Fieldtype that stores a reference to a single image from another page. The image can be selected with the associated Inputfield.
      Inputfield Select Image From Page is an Inputfield to select a single image from images on a predefined page and it's children.
      And there also is a helper module that takes care of cleanup tasks.
      This module evolved out of a discussion about my other Module FieldtypeImagePicker.  It caters for use cases where a set of images is being reused multiple times across a site. With this fieldtype these images can be administered through a chosen page. All images uploaded to that page will be available in the inputfield.
      When to use ?
      Let editors choose an image from a set of images that is being used site-wide. Ideal for images that are being re-used across the site.
      Suited for images that are used on multiple pages throughout the site (e.g. icons).
      Other than the native ProcessWire images field, the images here are not stored per page. Only references to images on another page are stored. This has several advantages:
      one central place to organize images when images change, you only have to update them in one place. All references will be updated, too. (Provided the name of the image that has changed stays the same) Features
      Images can be manipulated like native ProcessWire images (resizing, cropping etc.) Image names are fully searchable through the API Accidental image deletion is prevented. When you want to delete an image from one of the pages that hold your site-wide images, the module searches all pages that use that image. If any page contains a reference to the image you are trying to delete, deletion will be prevented. You will get an error message to help you edit those pages and remove references there before you can finally delete the image. How to install and setup
      Download and install this module like any other modules in ProcessWire Create a page in the page tree that will hold your images. This page's template must have an images field Upload some images to the page you created in step 2 Create a new field. As type choose 'Image Reference From Another Page'. Save the field. In 'Details' Tab of the field choose the page you created in step 2 Click Save button Choose the images field name for the field that holds your images (on page template from step 2) Click Save button again Choose whether you want to include child pages of page from step 2 to supply images Add the field to any template You are now ready to use the field View of the inputfield on the page edit screen:

      View of the field settings

      The module can be installed from this github repo. Some more info in the README there, too.
      In my tests it was fairly stable. After receiving your valued feedback, I will eventually add it to the modules directory.
      My ideas for further improvement:
      - add ajax loading of thumbnails
      Happy to hear your feedback!
       
    • By gebeer
      Although the PW backend is really intuitive, ever so often my clients need some assistance. Be it they are not so tech savvy or they are not working in the backend often.
      For those cases it is nice to make some help videos available to editors. This is what this module does.
      ProcessHelpVideos Module
      A Process module to display help videos for the ProcessWire CMS. It can be used to make help videos (screencasts) available to content editors.
      This module adds a 'Help Videos" section to the ProcessWire backend. The help videos are accessible through an automatically created page in the Admin page tree. You can add your help videos as pages in the page tree. The module adds a hidden page to the page tree that acts as parent page for the help video pages. All necessary fields and templates will be installed automatically. If there are already a CKEditor field and/or a file field for mp4 files installed in the system, the module will use those. Otherwise it will create the necessary fields. Also the necessary templates for the parent help videos page and it's children are created on module install. The module installs a permission process-helpvideos. Every user role that should have access to the help video section, needs this permission. I use the help video approach on quite a few production sites. It is stable so far and well received by site owners/editors. Up until now I installed required fields, templates and pages manually and then added the module. Now I added all this logic to the install method of the module and it should be ready to share.
      The module and further description on how to use it is available on github: https://github.com/gebeer/ProcessHelpVideos
      If you like to give it a try, I am happy to receive your comments/suggestions here.
    • By Robin S
      A module created in response to the topic here:
      Page List Select Multiple Quickly
      Modifies PageListSelectMultiple to allow you to select multiple pages without the tree closing every time you select a page.
      The screencast says it all:

       
      https://github.com/Toutouwai/PageListSelectMultipleQuickly
      https://modules.processwire.com/modules/page-list-select-multiple-quickly/
    • By gebeer
      Hello all,
      sharing my new module FieldtypeImagePicker. It provides a configurable input field for choosing any type of image from a predefined folder.
      The need for it came up because a client had a custom SVG icon set and I wanted the editors to be able to choose an icon in the page editor.
      It can also be used to offer a choice of images that are used site-wide without having to upload them to individual pages.
      There are no image manipulation methods like with the native PW image field.
      Module and full description can be found on github https://github.com/gebeer/FieldtypeImagePicker
      Kudos to @Martijn Geerts. I used his module FieldTypeSelectFile as a base to build upon.
      Here's how the input field looks like in the page editor:

      Hope it can be of use to someone.
      If you like to give it a try, I'm happy to hear your comments or suggestions for improvement. Eventually this will go in the module directory soon, too.
    • By bernhard
      @Sergio asked about the pdf creation process in the showcase thread about my 360° feedback/survey tool and so I went ahead and set my little pdf helper module to public.
      Description from PW Weekly:
       
      Modules Directory: https://modules.processwire.com/modules/rock-pdf/
      Download & Docs: https://github.com/BernhardBaumrock/RockPDF
       
      You can combine it easily with RockReplacer: 
      See also a little showcase of the RockPdf module in this thread:
       
×
×
  • Create New...