Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
QUESTION I need add a "href atribute" to CKeditor out format value
#4
The thread opener has obviously lost interest to discuss his matter. After nearly 4 years, even the best answers won't reach him anymore.

Therefore, I'll try to address frequent questions like his on a more general level. At least if one uses own servers, there is a very simple and elegant way to realize such "feature requests" for your own in a simple and elegant way without even touching the code or integrity of GetSimple itself. (This may also work on shared hosting if certain web server configuration requirements are met.)

I'm talking about Apache's mod_substitute (other webserver software may have similar features). It allows on-the-fly string replacement just before the requested content is sent out, optionally based on simple or regular expression based pattern matching.

To take the opener's request as an example, a simple .htaccess containing the following lines would do the job:

Code:
SetOutputFilter SUBSTITUTE

Substitute 's|<a href="http:url">|<a href="http:url isconvert="1">|nq'

The initial line is only needed once, while there may be any number of substitute directives. Please note the "n" after the closing "|" which tells Substitute to perform simple pattern matching without considering it a regular expression. So this would do a replacement of only one specific pattern on the left side by that on the right side.

For more generic replacements, e.g. for any URL, it could be done by using regular expressions:

Code:
Substitute 's|<a href="([^>]*)>|<a href="$1 isvonvert="1">|q'

The expression within paranthesis means "all following characters up to, but not including the closing >", so it will match any string so far. The respective content will then be represented by the $1 on the right side.


mod_substitute is a very powerful tool and allows all kind of magic and output manipulation while leaving GetSimple itself (or any other content source) completely untouched. Sometimes, the only challenge is to find a pattern which is specific enough to not trigger substitution by unwanted conditions. Another limitation is that replacements can be only done within a "physical" output line, but not across lines. (At least I don't know any way.)
Reply


Messages In This Thread
RE: I need add a "href atribute" to CKeditor out format value - by mawel - 2021-02-04, 03:18:17



Users browsing this thread: 1 Guest(s)