I have a product search form that logs the submitted keywords to 'couch/snippets/product-search.log' as follows:
To display the results in the couch admin panel, I created a template:
Is there a way I could reverse the list ordering so the most recent log entries are output at the top. I'm not sure what other applications this could be used for, but I think this reverse functionality would be a good 'log' tag parameter addition.
***** Update: Found one way to do this with php - found it on a php.net manual note.
I'm not sure if this is the best way to accomplish this, let me know if you have any suggestions.
- Code: Select all
=======================[2012-02-06 21:20:30]======================= Keyword Test 1 =======================[2012-02-06 21:20:45]======================= Keyword Test 2
To display the results in the couch admin panel, I created a template:
- Code: Select all
<?php require_once( 'couch/cms.php' ); ?> <cms:template title='Product Search Log' executable='0' > <cms:editable name='search_log' type='message'> <p> <cms:nl2br><cms:embed 'product-search.log' /></cms:nl2br> </p> </cms:editable> </cms:template> <?php COUCH::invoke(); ?>
Is there a way I could reverse the list ordering so the most recent log entries are output at the top. I'm not sure what other applications this could be used for, but I think this reverse functionality would be a good 'log' tag parameter addition.
***** Update: Found one way to do this with php - found it on a php.net manual note.
- Code: Select all
<cms:nl2br><cms:php>$myfile = 'couch/snippets/product-search.log';$lines = file($myfile);for($i=count($lines);$i>0;$i--){echo $lines[$i];}</cms:php></cms:nl2br>
I'm not sure if this is the best way to accomplish this, let me know if you have any suggestions.