Forums » display_js(false) still includes default javascripts

RSS feed for this topic

Info

  1. I have a conditional section in my header, so that image gallery scripts are only called when on the browse pages. I originally had something that looked like this:

    <?php if ($bodyclass=='browse'):?>
    <script type="text/javascript" src="<?php echo WEB_ROOT;?>/themes/mythemename/common/galleryview/jquery.galleryview-2.1.1-pack.js"></script>
    <script type="text/javascript" src="<?php echo WEB_ROOT;?>/themes/mythemename/common/galleryview/jquery.timers-1.2.js"></script>
    <script type="text/javascript" src="<?php echo WEB_ROOT;?>/themes/mythemename/common/galleryview/jquery.easing.1.3.js"></script>
    <?php endif; ?>

    Now I've updated it to look like:

    <?php if ($bodyclass=='browse'):?>
    <?php queue_js('jquery.galleryview-2.1.1-pack', 'common/galleryview'); ?>
    <?php queue_js('jquery.timers-1.2', 'common/galleryview'); ?>
    <?php queue_js('jquery.easing.1.3', 'common/galleryview'); ?>
    <?php display_js(false); ?>
    <?php endif; ?>

    However I've noticed that even though I set display_js(false), the default Omeka javascripts are still being generated. I use the display_js() earlier in my header to get the Omeka defaults, so I don't really need them to be listed again.

  2. display_js isn't designed to be called more than once on a given page.

    For your purposes, it looks like you want something like this:

    <?php if ($bodyclass=='browse'):?>
    <?php queue_js('jquery.galleryview-2.1.1-pack', 'common/galleryview'); ?>
    <?php queue_js('jquery.timers-1.2', 'common/galleryview'); ?>
    <?php queue_js('jquery.easing.1.3', 'common/galleryview'); ?>
    <?php endif; ?>
    
    <?php display_js(); ?>

    That call to display_js, which is outside your conditional, should be the only one in the header.

  3. Thanks.

Reply

You must log in to post.