Forum for discussing general topics related to Couch.
5 posts Page 1 of 1
I'm playing around CouchCMS and it comes very handy to use <cms:log -something- />.
I hope someone could hint me why this simple code creates a log file, where that -something- outputs twice.

Code: Select all
<?php require_once'admin/cms.php'; ?>
<!DOCTYPE html>
<html lang="ru">
<head></head>
<body>
       
        <ul>

      <cms:log k_is_list />
      
        </ul>


<!-- Yandex.Metrika counter -->
<script type="text/javascript">
(function (d, w, c) {
    (w[c] = w[c] || []).push(function() {
        try {
            w.yaCounter25031039 = new Ya.Metrika({id:25031039,
                    webvisor:true,
                    clickmap:true,
                    trackLinks:true});
        } catch(e) { }
    });

    var n = d.getElementsByTagName("script")[0],
        s = d.createElement("script"),
        f = function () { n.parentNode.insertBefore(s, n); };
    s.type = "text/javascript";
    s.async = true;
    s.src = (d.location.protocol == "https:" ? "https:" : "http:") + "//mc.yandex.ru/metrika/watch.js";

    if (w.opera == "[object Opera]") {
        d.addEventListener("DOMContentLoaded", f, false);
    } else { f(); }
})(document, window, "yandex_metrika_callbacks");
</script>
<!-- /Yandex.Metrika counter -->
      
</body>
</html>
<?php COUCH::invoke(); ?>


So, the output to log.txt goes like this:

=======================[2014-05-22 16:09:19]=======================
1

=======================[2014-05-22 16:09:21]=======================
1


I'm in no way a JS-programmer, and I guess, Couch does everything fine. However all my sites would have this Y counter. I just don't want the things get messed somehow.

I'm new here, so hello everybody from Ryazan, RUS and God bless the people created & contributing to CouchCMS.
Hello and welcome to our forums, Ryazan :)

I tested out your code and following is what seems to be happening -

When your browser loads the page, cms:log prints out the line, as expected.
Further down the JS code injects a .js file (http://mc.yandex.ru/metrika/watch.js) into the page.
This file upon loading calls the parent again thus effectively executing the page twice.
Hence you see the log statement twice.

So, the 'problem' is with the JS code being used.

Hope this helps.
Thank you, KK.
I will probably ask the guys from Yandex why their piece doubles the load time of any page with it 8-0.

Just by the way - is there any tag or smth to clear the log (or effectively delete log.txt) before -something- is written to it?
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
Ryazan, the cms:log tag is actually meant to be a debugging feature (e.g. mapping out the sequence of execution of your code etc.).
I am not sure if you are using it for its intended purpose.

Anyways, replying to your question - there is no Couch tag to clear the log file or delete it but we can always fall back on PHP to do things Couch cannot.
The log file has a fixed location so a bit of
Code: Select all
<cms:php> 
   ..  PHP code deleting the log file here ..
</cms:php>

before the cms:log should do it.

Do you think you'd be able to manage that?
:P :D

Well, as now "G" stands for Google, I didn't pray and got smth like this.

Code: Select all
<cms:php> 
   unlink('log.html');
</cms:php>


I used log to study variables, available in every piece of code as i'm couchifying a complicated (for me) image gallery with dynamic folders.
Thank you for you grace and presence, KK.
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
5 posts Page 1 of 1
cron