Explore the community Forums Lectora Lectora Questions & Answers if statement crashes module…

Tagged: 

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #299959 Score: 0
    Profile photo of Reiner Fuest
    Reiner Fuest
    Member
    beginner
    intermediate
    contributor
    @rfuest6134

    When adding an if statement in a header script which works fine so far, the module crashes and is published without layout and graphics. What might be wrong? I can not see an error in the JavaScript.

    I would linkt to add an opt out function for (not) tracking user activities with piwik. The piwik code works fine. When sourrounding die piwik code with an if statement reacting on a userdefined variable (line 5 and 24), eyerything goes wrong.

    <!– Seitentitel anpassen –>
    document.title = VarCurrentTitleName.getValue() + “: ” + VarCurrentPageName.getValue();
    <!– Piwik –>
    <!– wenn kein opt-out –>
    if (VarPiwikStatus.getValue() == “on”) {
    var _paq = _paq || [];
    (function(){
    var u=((“https:” == document.location.protocol) ? “https://piwik.URL/” : “http://piwik.URL/”);
    _paq.push([‘setSiteId’, 15]);
    _paq.push([‘setTrackerUrl’, u+’piwik.php’]);
    _paq.push([‘setVisitorCookieTimeout’, ‘604800’]);
    _paq.push([‘setSessionCookieTimeout’, ‘0’]);
    _paq.push([‘trackPageView’]);
    _paq.push([‘enableLinkTracking’]);
    var d=document,
    g=d.createElement(‘script’),
    s=d.getElementsByTagName(‘script’)[0];
    g.type=’text/javascript’;
    g.defer=true;
    g.async=true;
    g.src=u+’piwik.js’;
    s.parentNode.insertBefore(g,s);
    })();
    }
    <!– End Piwik Code –>

    Ofcourse there is an opt out code provided by piwik and it could be customized and inserted into an iframe. I will try this next, but an if statement should also work.

    #299960 Score: 0
    Profile photo of Reiner Fuest
    Reiner Fuest
    Member
    beginner
    intermediate
    contributor
    @rfuest6134

    Solved!

    Required variables must be defined…

    Sorry for disturbing you.

    #299963 Score: 0
    Profile photo of Jennifer Valley
    Jennifer Valley
    Member
    contributor
    beginner
    friend finder
    advanced
    lectora beginner
    verified member
    wise owl
    profile
    picture perfect
    curious george
    117 pts
    @jvalley4735

    Great detective skills @rfuest6134!

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.