AndZyk Posted January 29, 2020 Share Posted January 29, 2020 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 Link to comment Share on other sites More sharing options...
louisstephens Posted January 29, 2020 Share Posted January 29, 2020 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. 1 Link to comment Share on other sites More sharing options...
AndZyk Posted January 30, 2020 Author Share Posted January 30, 2020 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. ? Link to comment Share on other sites More sharing options...
louisstephens Posted January 30, 2020 Share Posted January 30, 2020 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. Link to comment Share on other sites More sharing options...
AndZyk Posted March 25, 2020 Author Share Posted March 25, 2020 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 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now