Author: dr Date: Tue Dec 18 10:54:32 2007 New Revision: 7020 Log: - Update after Alex' comments.
Modified: docs/articles/2007-12-20-tree-yui.txt Modified: docs/articles/2007-12-20-tree-yui.txt ============================================================================== --- docs/articles/2007-12-20-tree-yui.txt [iso-8859-1] (original) +++ docs/articles/2007-12-20-tree-yui.txt [iso-8859-1] Tue Dec 18 10:54:32 2007 @@ -64,21 +64,21 @@ .. _`eZ Components`: http://ezcomponents.org/ There are several ways of storing a tree structure with the Tree component. -You can either use an `XML file`__ as tree definition, or one of the three -database__ tree backends. As we will not have to manipulate the tree structure -in our application, we will simply be using the ezcTreeXml class for tree -storage in this article. - -__ /s/ezcTreeXml +You can either use an XML file as tree definition through the ezcTreeXml_ +class, or one of the three database__ tree backends. As we will not have to +manipulate the tree structure in our application, we will simply be using the +ezcTreeXml_ class for tree storage in this article. + __ /s/ezcTreeDb +.. _ezcTreeXml: /s/ezcTreeXml Defining the structure ---------------------- Because we are using an XML file for the tree definition, it is important to -know the allowed structure of the XML. Our tutorial__ already describes the -format with a Relax-NG schema, but that can be somewhat hard to read. Below -you will find a Relax-NG-Compressed schema:: +know the allowed structure of the XML. The ezcTreeXml_ class documentation +already describes the format with a Relax-NG schema, but that can be somewhat +hard to read. Below you will find a Relax-NG-Compressed schema:: default namespace = "http://components.ez.no/Tree" namespace etd = "http://components.ez.no/Tree/data" @@ -103,8 +103,6 @@ #. The "node" definition says that the "node" element requires the attribute "id" #. The "node" element can have an optional "data" element from the namespace "etd" #. The "node" element can have zero to many "node" elements as children - -__ /s/Tree As we're first looking at the structure only, we'll leave out the data parts for now. A part of the structure of our site as XML file looks like the @@ -134,11 +132,10 @@ </node> </tree> -We can load the tree structure with the following code:: +We can load the tree structure with the following code [#]_ :: <?php - ini_set( 'include_path', '/home/derick/dev/ezcomponents/trunk:.' ); - require 'Base/src/ezc_bootstrap.php'; + require 'ezc/Base/ezc_bootstrap.php'; // load the tree $tree = new ezcTreeXml( 'tree.xml', new ezcTreeXmlInternalDataStore() ); @@ -188,8 +185,7 @@ tree:: <?php - ini_set( 'include_path', '/home/derick/dev/ezcomponents/trunk:.' ); - require 'Base/src/ezc_bootstrap.php'; + require 'ezc/Base/ezc_bootstrap.php'; class ezcaTreeXmlDataStore extends ezcTreeXmlInternalDataStore { @@ -254,8 +250,7 @@ last line changed to allow dumping an array:: <?php - ini_set( 'include_path', '/home/derick/dev/ezcomponents/trunk:.' ); - require 'Base/src/ezc_bootstrap.php'; + require 'ezc/Base/ezc_bootstrap.php'; class ezcaTreeXmlDataStore extends ezcTreeXmlInternalDataStore { @@ -306,8 +301,8 @@ string(13) "Documentation" } -The full example can be found in the archive with examples with the filename -``extend1.php``. +The full example can be found in the downloadable archive (see left menu) with +examples with the filename ``extend1.php``. Example renderings ------------------ @@ -373,7 +368,7 @@ The original class had instead of the ``->data[1]`` bits ``->id``. When we modify the original script to use to new inherited visitor, -ezcaTreeVisitorPlainText, the output turns into the more pleasent display +ezcaTreeVisitorPlainText, the output turns into the more pleasant display below:: Homepage @@ -431,7 +426,7 @@ The PHP code to generate the menu in the way YUI wants, is again very simple. We just use the ezcTreeVisiterYUI__ class instead of the -ezcTreeVisitorPlainText class that we used before:: +ezcTreeVisitorPlainText_ class that we used before:: // display the tree $visitor = new ezcTreeVisitorYUI( 'menu' ); @@ -490,7 +485,8 @@ </script> When we tie everything together, we end up with the following code to render -the menu YUI style:: +the menu YUI style. This example can be found in the downloadable archive +(see left menu) with examples with the filename ``full1.php``:: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> @@ -511,8 +507,7 @@ </head> <body class="yui-skin-sam"> <?php - ini_set( 'include_path', '/home/derick/dev/ezcomponents/trunk:.' ); - require 'Base/src/ezc_bootstrap.php'; + require 'ezc/Base/ezc_bootstrap.php'; class ezcaTreeXmlDataStore extends ezcTreeXmlInternalDataStore { @@ -612,7 +607,7 @@ special trick for rendering images in their widgets. Instead of having a little image file for each element, they instead use a "sprite" file containing **all** the elements. From this they just cut out the part they -need. Some information about this techinique can be found here__. As we want +need. Some information about this technique can be found here__. As we want to change the arrow images, I created my own "sprite" to be used for those two elements. The sprite file is here__. @@ -658,6 +653,9 @@ <link rel="stylesheet" type="text/css" href="ezc.css"/> +The full example can be found in the downloadable archive (see left menu) with +examples with the filename ``full2.php``. + Conclusion ========== @@ -670,6 +668,11 @@ __ http://developer.yahoo.com/yui/menu + +.. [#] Note: The examples use eZ Components as installed with the PEAR + Installer. See http://ezcomponents.org/docs/install for an + introductionaty installation guide. + Resources ========= -- svn-components mailing list svn-components@lists.ez.no http://lists.ez.no/mailman/listinfo/svn-components