Coded something up in Couch in an interesting way? Have a snippet or shortcode to share? Post it here for the community to benefit.
3 posts Page 1 of 1
Tired of writing in file names? :lol:
Optimized solution for viewing in browser.

Code: Select all
$FUNCS->add_event_listener( 'alter_tag_log_execute', array('CustomTags', 'log_with_file') );


class CustomTags{

   function log_with_file( $tag_name, $params, $node, &$res ){
      global $CTX, $FUNCS;
      if( count($node->children) ) {die("ERROR: Tag \"".$node->name."\" is a self closing tag");}

      extract( $FUNCS->get_named_vars(
               array(
                    'msg'=>'',
                    'file'=>'log-'.date( "n-j" ).'.html'
                    ),
               $params)
            );
      if( !trim($msg) ){
         global $TAGS;
         $msg = $TAGS->dump_all( $params, $node );
      }
      $FUNCS->log( '<br/>' . $msg . '<br/>', trim($file) );
      return 1;
   }
}


By default, without file parameter, logfile will be created in root of website with the name log-11-17.html, with current month-date( log-{m}-{d}.html ).
Using with both options( with file parameter or without ):
Code: Select all
<cms:log variable />
<cms:log "<cms:dump_all />" />
<cms:log variable file='some-better-name.log' />
Added a little mod to skip message( msg ) completely. That part:
Code: Select all
...
      if( !trim($msg) ){
         $msg = new KTags();
         $msg = $msg->dump_all( $params, $node );
      }
...

or would be even better with
...
      if( !trim($msg) ){
         global $TAGS;
         $msg = $TAGS->dump_all( $params, $node );
      }
...

Usage is super-simple:
Code: Select all
<cms:log />
// instead of
<cms:log "<cms:dump_all />" />
Updated with working solution for logging dump_all instead of empty message.
ScreenCut-12-06---12-19-22-.png
Autonaming
ScreenCut-12-06---12-19-22-.png (1.72 KiB) Viewed 654 times
3 posts Page 1 of 1

Who is online

In total there are 3 users online :: 0 registered, 0 hidden and 3 guests
(based on users active over the past 5 minutes)

Users browsing this forum: No registered users and 3 guests