wszystko super dziala jesli mam tylko jeden modul z np. 6zakladkami. Problem pojawia sie gdy chce dodac drug modul na zakladki z innego tematu niz poprzednie.

Tworze sobie kopie plikow pod inna nazwa, oczywiscie w kazdym pliku nadpisuje poprawne nazwy. Doszedlem skad wynika blad, niestety nie mam pojecia dlaczego on tam wystepuje i jak go naprawic.

Mam dwa pliki:
mod_front_ajaxtabs.php ktory wyswietla wszystkie zakladki, w nim jest deklaracja ul, ktore posiada id="maintab" a na samym dole jest jego wywolanie.
Drugi plik to plik js z silnikiem zakladek, niestety nie widze w nim nic o maintab i jej zadaniu sad.gif

Zemy byla mozliwosc powielania modulow z zakladkami te ul'e musza miec rozne id, tylko jak je zmienie na inne to wogole sie nie wyswietlaja zakladki(tylko w danym module)

co robic ?

mod_front_ajaxtabs.php
  1. <?php
  2. <head>
  3. <link rel="stylesheet" type="text/css" href="../modules/front_ajaxtabs/front_ajaxtabs.css" />
  4.  
  5. <script type="text/javascript" src="../front_ajaxtabs/front_ajaxtabs.js"></script>
  6.  
  7. </head>
  8.  
  9. <body>
  10. <div class="clear"></div>
  11. <ul id="maintab" class="shadetabs2">
  12. <li class="front_selected"><a href="#" rel="tcontent11">Wszystko o drogach</a></li>
  13. <li class="tabs"><a href="#" rel="tcontent12">Nowo¶ci</a></li>
  14. </ul>
  15.  
  16. <div class="front_tabcontentstyle">
  17.  
  18. <div id="tcontent11" class="tabcontent">
  19.  
  20. <table border="0" width="530" height="236" cellpadding="0" cellspacing="0">
  21. <tr>
  22. <td>gggg
  23.  
  24. </td>
  25. </tr>
  26. </table>
  27. </div>
  28.  
  29. <div id="tcontent12" class="tabcontent">
  30. <table>
  31. <tr><td>ppp</td></tr>
  32.  
  33. </table>
  34. </div>
  35.  
  36. </div>
  37.  
  38. <script type="text/javascript">
  39. //Start Tab Content script for UL with id="maintab" Separate multiple ids each with a comma.
  40. initializefront_tabcontent("maintab")
  41. </script>
  42.  
  43. </body>
  44. ?>


js
  1. <?php
  2. //** Tab Content script- © Dynamic Drive DHTML code library (http://www.dynamicdrive.com)
  3. //** Last updated: Nov 8th, 06
  4.  
  5. var enabletabpersistence=1 //enable tab persistence via session only cookies, so selected tab is remembered?
  6.  
  7. ////NO NEED TO EDIT BELOW////////////////////////
  8. var tabcontentIDs=new Object()
  9.  
  10. function expandcontent(linkobj){
  11. var ulid=linkobj.parentNode.parentNode.id //id of UL element
  12. var ullist=document.getElementById(ulid).getElementsByTagName("li") //get list of LIs corresponding to the tab contents
  13. for (var i=0; i<ullist.length; i++){
  14. ullist[i].className="" //deselect all tabs
  15. if (typeof tabcontentIDs[ulid][i]!="undefined") //if tab content within this array index exists (exception: More tabs than there are tab contents)
  16. document.getElementById(tabcontentIDs[ulid][i]).style.display="none" //hide all tab contents
  17. }
  18. linkobj.parentNode.className="front_selected" //highlight currently clicked on tab
  19. document.getElementById(linkobj.getAttribute("rel")).style.display="block" //expand corresponding tab content
  20. saveselectedtabcontentid(ulid, linkobj.getAttribute("rel"))
  21. }
  22.  
  23. function expandtab(tabcontentid, tabnumber){ //interface for selecting a tab (plus expand corresponding content)
  24. var thetab=document.getElementById(tabcontentid).getElementsByTagName("a")[tabnumber]
  25. if (thetab.getAttribute("rel"))
  26. expandcontent(thetab)
  27. }
  28.  
  29. function savetabcontentids(ulid, relattribute){// save ids of tab content divs
  30. if (typeof tabcontentIDs[ulid]=="undefined") //if this array doesn't exist yet
  31. tabcontentIDs[ulid]=new Array()
  32. tabcontentIDs[ulid][tabcontentIDs[ulid].length]=relattribute
  33. }
  34.  
  35. function saveselectedtabcontentid(ulid, selectedtabid){ //set id of clicked on tab as selected tab id & enter into cookie
  36. if (enabletabpersistence==1) //if persistence feature turned on
  37. setCookie(ulid, selectedtabid)
  38. }
  39.  
  40. function getullistlinkbyId(ulid, tabcontentid){ //returns a tab link based on the ID of the associated tab content
  41. var ullist=document.getElementById(ulid).getElementsByTagName("li")
  42. for (var i=0; i<ullist.length; i++){
  43. if (ullist[i].getElementsByTagName("a")[0].getAttribute("rel")==tabcontentid){
  44. return ullist[i].getElementsByTagName("a")[0]
  45. break
  46. }
  47. }
  48. }
  49.  
  50. function initializetabcontent(){
  51. for (var i=0; i<arguments.length; i++){ //loop through passed UL ids
  52. if (enabletabpersistence==0 && getCookie(arguments[i])!="") //clean up cookie if persist=off
  53. setCookie(arguments[i], "")
  54. var clickedontab=getCookie(arguments[i]) //retrieve ID of last clicked on tab from cookie, if any
  55. var ulobj=document.getElementById(arguments[i])
  56. var ulist=ulobj.getElementsByTagName("li") //array containing the LI elements within UL
  57. for (var x=0; x<ulist.length; x++){ //loop through each LI element
  58. var ulistlink=ulist[x].getElementsByTagName("a")[0]
  59. if (ulistlink.getAttribute("rel")){
  60. savetabcontentids(arguments[i], ulistlink.getAttribute("rel")) //save id of each tab content as loop runs
  61. ulistlink.onclick=function(){
  62. expandcontent(this)
  63. return false
  64. }
  65. if (ulist[x].className=="front_selected" && clickedontab=="") //if a tab is set to be selected by default
  66. expandcontent(ulistlink) //auto load currenly selected tab content
  67. }
  68. } //end inner for loop
  69. if (clickedontab!=""){ //if a tab has been previously clicked on per the cookie value
  70. var culistlink=getullistlinkbyId(arguments[i], clickedontab)
  71. if (typeof culistlink!="undefined") //if match found between tabcontent id and rel attribute value
  72. expandcontent(culistlink) //auto load currenly selected tab content
  73. else //else if no match found between tabcontent id and rel attribute value (cookie mis-association)
  74. expandcontent(ulist[0].getElementsByTagName("a")[0]) //just auto load first tab instead
  75. }
  76. } //end outer for loop
  77. }
  78.  
  79.  
  80. function getCookie(Name){ 
  81. var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
  82. if (document.cookie.match(re)) //if cookie found
  83. return document.cookie.match(re)[0].split("=")[1] //return its value
  84. return ""
  85. }
  86.  
  87. function setCookie(name, value){
  88. document.cookie = name+"="+value //cookie value is domain wide (path=/)
  89. }
  90. ?>


nie wiem czy dobrze, ale dziala dry.gif

do kazdego pliku z zakladkami (php)
na koncu dopisuje po przecinku nowe id tego ul np.
  1. <?php
  2. initializetabcontent("maintab","maintab2")
  3. ?>