Hi, ready to hack a bit? :)

Tag cms:pages has a custom_field parameter, which can help filter certain pages.
Code: Select all
<cms:pages masterpage='blog.php' custom_field='my_blog_author=jeffrey, arthur'></cms:pages>

The code above shows pages of blog.php, with editable named 'my_blog_author' containing the word 'jeffrey' or 'arthur' anywhere within it. So, comma is separating 2 values from each other. Sometimes I need to look for pages, containing a phrase with multiple words in custom_field. Such a phrase with multiple words can have a comma, of course.
Code: Select all
<cms:pages masterpage='family.php' custom_field='person=jeffrey, my son'></cms:pages>

The code above was erroneously intended to output only page with a certain family relative, named "jeffrey, my son", and not "jeffrey, my uncle". Instead, the code will show both pages, which contain word 'jeffrey'. Therefore to avoid undesired results, comma is something that must be treated - just like we treat quotes. Normally, we 'escape' quotes with cms:addslashes. However, this tag takes care of quotes only.
It's time to change that.
Code: Select all
        function addslashes( $params, $node ){
            global $FUNCS;
            extract( $FUNCS->get_named_vars(
                        array(
                               'quote'=>''
                              ),
                        $params)
                   );
            $quote = strtolower( trim($quote) );

            // call the children
            foreach( $node->children as $child ){
                $html .= $child->get_HTML();
            }

            if( $quote=='single' ){
                $html = str_replace( "'", "\'", $html );
            }
            else{ // default is double-quote
                $html = str_replace( '"', '\"', $html );
            }
            return $html;
        }

Above is the code for tag, as found in /couch-folder/tags.php, Line 5703.
Now, modify it like this:
Code: Select all
        function addslashes( $params, $node ){
            global $FUNCS;
            extract( $FUNCS->get_named_vars(
                        array(
                               'quote'=>'',
                               'comma'=>'0'
                              ),
                        $params)
                   );
            $quote = strtolower( trim($quote) );
            $comma = ( $comma==1 ) ? 1 : 0;
         
            // call the children
            foreach( $node->children as $child ){
                $html .= $child->get_HTML();
            }

            if( $comma=='1' ){
                $html = str_replace( ",", "\,", $html );
            }

            if( $quote=='single' ){
                $html = str_replace( "'", "\'", $html );
            }
            else{ // default is double-quote
                $html = str_replace( '"', '\"', $html );
            }
            return $html;
        }

After the modification, the tag is used like this:
Code: Select all
<cms:addslashes comma='1'>jeffrey, my son</cms:addslashes>

It should be enough to use phrases with commas in custom_field. Cool!

Would be useful in situations where the input is not known before hand (e.g. search forms). For fixed strings, we can of course easily escape the comma manually.