Fix for Fix for menuRoids on Meth...

  1. FUNCTION theme_convert_menu($menusource){
  2. $themed_menu = new DOMDocument();
  3. @$themed_menu->loadXML($menusource);
  4. $templateSource = <<<TEMPLATESOURCE
  5. <?xml version="1.0" encoding="ISO-8859-1"?>
  6. <xsl:stylesheet version="1.0"
  7. xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  8. <xsl:template match="/">
  9.         <xsl:for-each SELECT="node()|@*[not(.='')]">
  10.                 <xsl:copy SELECT="node()">
  11.                         <xsl:copy-of SELECT="@*[not(.='')]"/>
  12.                         <xsl:apply-templates />
  13.                 </xsl:copy>
  14.         </xsl:for-each>
  15. </xsl:template>
  16. <xsl:template match="a">
  17.    <a>
  18.    <xsl:copy-of SELECT="@*[not(.='')]"/>
  19.    <span>
  20.    <xsl:copy-of SELECT="node()"/>
  21.    </span>
  22.    </a>
  23. </xsl:template>
  24. <xsl:template match="ul">
  25.    <ul>
  26.    <xsl:copy-of SELECT="@*[not(.='')]"/>
  27.    <xsl:copy-of SELECT="node()"/>
  28.    </ul>
  29. </xsl:template>
  30. <xsl:template match="ul/li/ul/li">
  31.    <li>
  32.      <xsl:copy-of SELECT="node()">
  33.         <xsl:apply-templates SELECT="(ul|li|a)"/>
  34.      </xsl:copy-of>
  35.    </li>
  36. </xsl:template>
  37. <xsl:template match="li">
  38.    <xsl:copy SELECT="node()|@*[not(.='')]">
  39.           <xsl:copy-of SELECT="@*[not(.='')]"/>
  40.           <xsl:apply-templates/>
  41.         </xsl:copy>
  42. </xsl:template>
  43. <xsl:template match="ul[@id='nav']/li/ul">
  44.   <div class="subnav">
  45.     <span class="top-bg">&#160;</span>
  46.       <div class="bg">
  47.         <div>
  48.                    <xsl:copy SELECT="node()|@*[not(.='')]">
  49.                                 <xsl:apply-templates/>
  50.                    </xsl:copy>
  51.         </div>
  52.       </div>
  53.       <span class="bottom-bg">&#160;</span>
  54.     </div>  
  55. </xsl:template>
  56. <xsl:template match="ul[@id='nav']/li//ul/li">
  57.                 <xsl:copy  SELECT="node()">
  58.                         <xsl:apply-templates/>
  59.                 </xsl:copy>
  60. </xsl:template>
  61. <xsl:template match="ul[@id='nav']/li//ul/li/ul">
  62.                 <xsl:copy SELECT="node()">
  63.                         <xsl:apply-templates/>
  64.                 </xsl:copy>
  65. </xsl:template>
  66. </xsl:stylesheet>
  67. TEMPLATESOURCE;
  68.         $xpath = new domXPath($themed_menu);
  69.         $xpathQuery = $xpath->query("/ul/li");
  70.         $topItemCount = 0;
  71.         foreach($xpathQuery AS $topItem){
  72.                 IF(++$topItemCount > 5)
  73.                         $topItem->appendChild($themed_menu->createAttribute('class'))->appendChild($themed_menu->createTextNode('absolut'));
  74.         }unset($topItem,$topItemCount,$xpath,$xpathQuery);
  75.         $stylesheet = new DOMDocument();       
  76.         $stylesheet->loadXML($templateSource);
  77.         unset($templateSource);
  78.         $xsl = new XSLTProcessor();    
  79.         $xsl->importStyleSheet($stylesheet);
  80.         unset($stylesheet);
  81.         $temp = new DOMDocument();
  82.         @$temp->loadXML($xsl->transformToXML($themed_menu));
  83.         unset($xsl);           
  84.         $Menu = stripDOMoutPut($temp);
  85.         RETURN $Menu;  
  86. }
  87.  
  88.  
  89. IN my tpl...
  90. diamond_convert_menu($menu)

Submit Fix

Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Select the syntax highlighting mode to use.