Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
possibility of html output filtering
#1
I am thinking about following:

in page source code which I can see via admin-interface I can insert many things like comments, which are only interesting for me and not for the users who see the page. So it is ok that these special tags are stored in page-xml - but it is not necessary (or sometimes NOT WANTED) that these tags are transferred to page content viewable via http.

So I am thinking about a possibility of "output-filtering". In perfect way this could be a plugin where you can add tags which are cut when page is delivered to webserver. In simple&quick this could be a textfile where line by line such tags can be listed. I don't think this eats much performance because there is almost filtering / buliding necessary to create page from xlm and there are only few tags which must be remove additional.

Example:

If I don't want to deliver comments or internal tags which are only for development purposes I bulid a text file containing
PHP Code:
<!--*-->
<
span class="testonly">*</span

to remove all comments and testonly-spans before transferring to the internet.

My questions are:
1) In which php at what line must be implemented such a function?
2) Is it possible to add this via plugin - so may be I start to write such a plugin.

Shortening output to necessary contents and removing everything that is not related to users is a good and wanted thing...

Best regards
Andreas
Reply
#2
Yes, all plugins have this at their disposition. Have a look at http://get-simple.info/wiki/plugins:hooks_filters.
Basically in your plugin file you just do:

PHP Code:
<?php
function myFilter($content) {
  
$regex '~<!--.*-->|<span class="testonly">.*</span>~'
  
return preg_replace($regex''$content);
}
add_filter('content''myFilter'); ?>
Reply
#3
(2015-07-24, 08:29:53)Tyblitz Wrote: Yes, all plugins have this at their disposition. Have a look at http://get-simple.info/wiki/plugins:hooks_filters.



Many thanks for your reply.

I have had to RTFM  Angel

Best regards
Andreas
Reply




Users browsing this thread: 1 Guest(s)