<h1>YUI PHP Loader Utility Advanced Example: Mixed Loading Methods</h1>

    <p>In this example, we bring a YUI component onto the page using the <a href="http://developer.yahoo.com/yui/phploader/">YUI PHP Loader Utility</a>. 
    This example implements YUI PHP Loader via a <code>YAHOO_util_Loader</code> instance.  We include the YUI PHP Loader class file, then specify in 
    configuration which component we want loaded on the page &mdash; and what we want to do once it <em>is</em> loaded.  The main difference between 
    this example and the previous advanced example is that we have mixed the component loading methods.  The Calender component requires the Yahoo, Dom, 
    and Event modules.  In the previous example we let PHP Loader bring these into the document for us.  However, in this case we placed a static 
    script include into the document that brings in these resources.  We do not wish to have PHP Loader duplicate the loading of these components so 
    we utilize the <em>setLoaded</em> method to notify PHP Loader that we already have these components in the document and to skip loading them a second time.</p>

    <div id="calendar_container"></div>

    <script type="text/javascript" src="http://yui.yahooapis.com/<?php 
echo $yuiCurrentVersion;
?>
/build/yahoo-dom-event/yahoo-dom-event.js"></script>
    <?php 
//Output the script tags (but don't re-include yahoo-dom-event)
$loader->setLoaded("yahoo", "dom", "event");
echo $loader->script();
?>
    <script type="text/javascript">
        YAHOO.util.Event.onAvailable("calendar_container", function() {
    		var myCal = new YAHOO.widget.Calendar("mycal_id", "calendar_container");
    		myCal.render();
    	})
    </script>
</body>
</html>
Exemplo n.º 2
0
$l6b->load("slider", "connection");
encoded_out($l6b->tags());
/* same as 6, but we add connection to trigger the utilities rollup */
//////////////////////////////////////////////////////////////////////////
encoded_out("\n\nTest 7:\n\n");
$l7 = new YAHOO_util_Loader(YUI_VERSION_TO_TEST);
$l7->load('editor');
$l7->skin['overrides']['button'] = array('skin1', 'skin2', 'skin3');
encoded_out($l7->tags());
/* The loader can be configured to support more than just javascript files.  */
//////////////////////////////////////////////////////////////////////////
encoded_out("\n\nTest 8:\n\n");
$l8 = new YAHOO_util_Loader(YUI_VERSION_TO_TEST);
$l8->load("treeview");
$l8->load("treeviewcss");
$l8->setLoaded("treeview");
encoded_out("<!-- css -->\n");
encoded_out($l8->css());
encoded_out("<!-- js -->\n");
encoded_out($l8->script());
/* separate css and js output */
//////////////////////////////////////////////////////////////////////////
encoded_out("\n\nTest 9:\n\n");
$l9 = new YAHOO_util_Loader(YUI_VERSION_TO_TEST);
$l9->load("calendar");
encoded_out($l9->json());
/* json */
//////////////////////////////////////////////////////////////////////////
encoded_out("\n\nTest 10:\n\n");
$l10 = new YAHOO_util_Loader(YUI_VERSION_TO_TEST);
$l10->load("calendar");