GGshow reloaded GGshow reloaded

February 3, 2012

Duplicated placeholder output

Issue:

  • Zend Framework placeholder (headTitle, headMeta, headLink, headScript, headStyle, inlineScript) creates twice or multiple title/meta/link/script tags in HTML.
  • Duplicated title/meta/link/script tags generated from Zend Framework placeholder.
  • e.g.:

    source:

    <?php echo $this->headScript()->appendFile("/scripts/global.js") ?>
    <?php echo $this->headScript()->appendFile("/scripts/main.js") ?>

    output:

    <script src="/scripts/global.js" type="text/javascript"></script>
    <script src="/scripts/global.js" type="text/javascript"></script>
    <script src="/scripts/main.js" type="text/javascript"></script>

Reason:

  • Echo will output all elements in a placeholder.

Solution:

  • Echo only once for each placeholder.
  • e.g.:
    <?php $this->headLink()->appendStylesheet('/styles/global.css') ?>
    <?php $this->headLink()->appendStylesheet('/styles/main.css') ?>
    <?php echo $this->headLink() ?>
    
    <?php $this->headScript()->appendFile("/scripts/global.js") ?>
    <?php $this->headScript()->appendFile("/scripts/main.js") ?>
    <?php echo $this->headScript() ?>
Filed under: CSS,JavaScript,PHP,Web,Zend Framework — Tags: , , — GG @ 11:15 am

1 Comment »

  1. Basically details! You actually solved the particular query My partner and i posted on StackOverflow.

    Comment by wildstar — July 8, 2014 @ 10:04 am

RSS feed for comments on this post.

Leave a comment

© 2024 GGSHOW | Powered by WordPress