Jump to content
AndZyk

Allow protocol file:// in FieldType URL and CKEditor links

Recommended Posts

Hello,

I am currently building a intranet which will be hosted on the local network of a company. This intranet has many links to files on their fileserver with the protocol file://.

So for example the links look like this file://domain.tld/filename.ext

  • When I try to insert such a link into a URL field, I get the error, that only the protocol http:// is allowed.
  • When I try to insert such a link into a CKEeditor link, it gets stripped out.

Is it possible to insert such links into the FieldType URL and CKEditor.

I know that I could use a FieldType Text or insert a RewriteRule in the .htaccess file, but I am looking for a more elegant solution. 😉

Regards, Andreas

Share this post


Link to post
Share on other sites

I have not truly vetted the plugin, but there is this official plugin via CKEditor. It let me select from various protocols and has an "other" selection. I was able to successfully use the file:// protocol inside the href without it getting stripped.

  • Like 1

Share this post


Link to post
Share on other sites

Thank you @louisstephens for the hint. I tried it out, but the link still gets stripped out, even with disabled ACF. Do you have configured extra allowed content?

Maybe a RewriteRule in the .htaccess file would be the easiest solution. 🤔

Share this post


Link to post
Share on other sites
4 hours ago, AndZyk said:

Thank you @louisstephens for the hint. I tried it out, but the link still gets stripped out, even with disabled ACF. Do you have configured extra allowed content?

Maybe a RewriteRule in the .htaccess file would be the easiest solution. 🤔

Ah, I did not have extra allowed content enabled, but it was a bit confusing for me as I had to add it to the toolbar and the icon appeared to be exactly like the current "url" icon. 

Share this post


Link to post
Share on other sites

My solution for textareas with CKEditor is now a simple Textformatter module. 😉

<?php
class TextformatterReplaceLinks extends Textformatter implements Module {

    public static function getModuleInfo() {
        return array(
            "title" => "Replace Links",
            "version" => "1.0.0",
            "summary" => "Find and replace links of domain.",
            "author" => "AndZyk",
            "singular" => true,
            "requires" => "ProcessWire>=2.6",
            "icon" => "link"
        );
    }

    /**
     * Find and replace the input string
     *
     * @param string $str The block of text to parse
     *
     * The incoming string is replaced with the formatted version of itself.
     *
     */

    public function format(&$str) {

        $str = preg_replace("/(http|https):\/\/example.com/", "file://example.com", $str);

    }
}

Regards, Andreas

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By AndréPortuga
      Does anyone knows if there is a way of selecting a iframe inside a textfield(using ckEditor)? 
      I mean I have a Iframe with this code:
      <iframe allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen="" frameborder="0" height="315" scrolling="no" src="https://www.youtube.com/embed/PMaFJjZDrYM" width="100%"></iframe></p>
       
      but it's not getting responsive in iPhones.. So anyone know how can I select it via code for making it responsive?
       
      Thank you,
    • By dragan
      On one particular site, CKEditor behaves rather weird:
      When I copy and paste "normally", i.e. CTRL + V, there is an alert popping up "do you really want to leave this page?". If you cancel, the text is pasted into the field. If not, you get redirected to the frontend of the page you just edited, and the changes are lost.
      The "paste from Word" button doesn't work. CTRL + SHIFT + V works, but all formatting is lost (apart from paragraphs).
      I'm using inline editor mode, ACF + Purifier are activated. I know that if I disable those two, CTRL + V works, but I won't do that, since CKE then saves all the garbage code from MS-Office.
      Has anyone ever come across this issue? I tried with Chrome + FF. No JS errors.
    • By prestoav
      Hi folks.
      I'm building a Formbuilder form to create new advert pages in a marketplace. Formbuilder is ideal for this. I need to add a description field that allows text to be added with line breaks etc. so showing a CKEditor field would be ideal (i.e. exactly like the field I'm typing into right now)!.
      Does anyone know if it's possible to add a CKEditor field to the front end presentation fo a Formbuilder field, maybe via a module or such?
      Many thanks!
    • By Roberts R
      Hello.
      I never though about it before but when I insert image into CKeditor field I don't get ALT tag filled from image that has it. Do I have to do it manualy for inserted image or Im doing something wrong?
       
    • By Robin S
      If you've ever needed to insert links to a large number of files within CKEditor you may have found that the standard PW link modal is a somewhat slow way to do it.
      This module provides a quicker way to insert links to files on the page being edited. You can insert a link to an individual file, or insert an unordered list of links to all files on the page with a single click.
      CKEditor Link Files
      Adds a menu to CKEditor to allow the quick insertion of links to files on the page being edited.

      Features
      Hover a menu item to see the "Description" of the corresponding file (if present). Click a menu item to insert a link to the corresponding file at the current cursor position. The filename is used as the link text. If you Alt-click a menu item the file description is used as the link text (with fallback to filename if no description entered). If text is currently selected in the editor then the selected text is used as the link text. Click "* Insert links to all files *" to insert an unordered list of links to all files on the page. Also works with the Alt-click option. Menu is built via AJAX so newly uploaded files are included in the menu without the page needing to be saved. However, descriptions are not available for newly uploaded files until the page is saved. There is an option in the module config to include files from Repeater fields in the edited page. Nested Repeater fields (files inside a Repeater inside another Repeater) are not supported. Installation
      Install the CKEditor Link Files module.
      For any CKEditor field where you want the "Insert link to file" dropdown menu to appear in the CKEditor toolbar, visit the field settings and add "LinkFilesMenu" to the "CKEditor Toolbar" settings field.
       
      http://modules.processwire.com/modules/cke-link-files/
      https://github.com/Toutouwai/CkeLinkFiles
×
×
  • Create New...