Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • annaleen Friend
    #149483

    I’m curious, why is there no < /body > tag in HTML as this tutorial suggested? :confused:

    histeriks Friend
    #336106

    annaleen;169275I’m curious, why is there no < /body > tag in HTML as this tutorial suggested? :confused:

    Hi annaleen,

    in fact, there IS a </body> tag in HTML, you can see it yourself if you view the source of your website.

    New JA templates are composed out of blocks, which are assembled in one page by file default.php (or other files if you’re using, for example, mobile view).

    When you open the url of your website, Joomla calls your template’s index.php file, which will first determine few conditions, such as your layout (default view, mobile view…), your text orientation (right to left, left to right), width of the template, and so on, and so on…

    After it determines all needed parameters, it will then call the appropriate file (default.php if it’s classic desktop view, handheld.php if you’re visiting the website with your handheld device etc).

    Then, for example, in case you’re viewing the website from your computer, default.php file from layouts directory of your template will be called and it will take all needed blocks (head, header, main body, footer, etc), assemble them in one whole page, which will then present you the content from the database in the html form you can view in the source of the website page.

    Examples from default.php:

    <head>
    <?php $this->loadBlock(‘head’) ?> <— This will be replaced by the content from head.php
    </head>

    <!– HEADER –>
    <?php $this->loadBlock(‘header’) ?> <— header.php contents will go here
    <!– //HEADER –>

    <!– MAIN NAVIGATION –>
    <?php $this->loadBlock(‘mainnav’) ?> <— mainnav.php contents will end up here
    <!– //MAIN NAVIGATION –>

    (other blocks will go here)

    <!– FOOTER –>
    <?php $this->loadBlock(‘footer’) ?> <— footer will end up here
    <!– //FOOTER –>

    </div>

    <jdoc:include type=”modules” name=”debug” />

    <?php if ($this->isIE6()) : ?>
    <?php $this->loadBlock(‘ie6/ie6warning’) ?>
    <?php endif; ?>

    </body> <— your closing body tag

    </html>

    You can see the closing </body> tag in default.php file, located in layouts directory inside your template dir on line 106, so, that would be a nice place for you to place your Google Analytics code (i guess you could also put it on the end of footer.php, since it will end up before closing body tag as well).

    Hope you’ll get the better picture from this rough explanation.

    Good luck 🙂

    annaleen Friend
    #336108

    Thank you but I’m still not clear as where to add the Google Analytics code in the HTML as in tutorial. 🙂

    histeriks Friend
    #336111

    annaleen;169287Thank you but I’m still not clear as where to add the Google Analytics code in the HTML as in tutorial. 🙂

    As i wrote on the end of my post, you could either put it in default.php, or in footer.php.

    Let’s go step by step.

    Open file default.php, located in your_site_root/templates/ja_rasite/layouts/ directory, and scroll down to line 100, where you’ll find this:

    <jdoc:include type="modules" name="debug" />

    <?php if ($this->isIE6()) : ?>
    <?php $this->loadBlock('ie6/ie6warning') ?>
    <?php endif; ?>

    </body>
    Now, just paste your code after <?php endif; ?> and before </body> tag, so that your default.php looks similar to this from line 100 afterwards:

    <jdoc:include type="modules" name="debug" />

    <?php if ($this->isIE6()) : ?>
    <?php $this->loadBlock('ie6/ie6warning') ?>
    <?php endif; ?>

    <script type="text/javascript">
    var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
    document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
    </script>
    <script type="text/javascript">
    try {
    var pageTracker = _gat._getTracker("YOUR_TRACKER_ID");
    pageTracker._trackPageview();
    } catch(err) {}</script>
    </body>

    If you get stuck, or if it’s not working, please throw a line here so we can continue 🙂

    annaleen Friend
    #336112

    Thank you for the detailed answer, you’re very kind! 😀

    histeriks Friend
    #336114

    annaleen;169291Thank you for the detailed answer, you’re very kind! 😀

    It was a pleasure! Thanks 🙂

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

This topic contains 6 replies, has 2 voices, and was last updated by  histeriks 14 years, 2 months ago.

We moved to new unified forum. Please post all new support queries in our New Forum