ApPHP Tabs Pro - Example of Code

Show Plain Text »
  1. <?php
  2.  
  3. ## +---------------------------------------------------------------------------+
  4. ## | 1. Creating & Calling:                                                    |
  5. ## +---------------------------------------------------------------------------+
  6. ## *** define a relative (virtual) path to tabs.class.php file
  7. define ("TABS_DIR", "");   /* Ex.: "tabs/" */
  8. ## *** include Tabs class
  9. require_once(TABS_DIR."tabs.class.php");
  10. ## *** create Tabs object
  11. $tabs = new Tabs();
  12.  
  13. ## +---------------------------------------------------------------------------+
  14. ## | 2. General Settings:                                                      |
  15. ## +---------------------------------------------------------------------------+
  16. ## *** set unique numeric (integer-valued) identifier for Tabs
  17. ## *** (if you want to use several independently configured Tabs objects on single page)
  18. $tabs->SetId(23);
  19. ##  *** set style for Tabs
  20. ##  *** "xp", "dark-red", "light-green", "g-style", "grey", "black" or your own style
  21. $tabs->SetStyle("g-style");
  22. ##  *** set Tabs direction - ltr|rtl
  23. /// $tabs->SetDirection("ltr");
  24. ## *** set Tabs caption
  25. /// $tabs->SetCaption("ApPHP Tabs v".Tabs::Version());
  26. ## *** show debug info - false|true
  27. $tabs->Debug(true);
  28. ## *** choose mode of displaying child tabs - links|dropdown|tabs
  29. $tabs->SetChildTabsType("dropdown");
  30. ## *** set form submission type: "get", "post" or "ajax"
  31. $tabs->SetSubmissionType("post");
  32. ## *** set variables that used to get access to the page (like: my_page.php?act=34&id=56 etc.)
  33. /// $tabs->SetHttpVars(array("id"));
  34. ##  *** allow refreshing selected tabs
  35. /// $tabs->AllowRefreshSelectedTabs(false);
  36. ## *** use an anchor to navigate to tabs object after a tab is clicked - true|false
  37. /// $tabs->UseAnchor(false);
  38. ## *** create the anchor automatically - true|false
  39. /// $tabs->CreateAnchorAuto(false);
  40. ## *** if the CreateAnchorAuto is set to true you have to create the anchor manually
  41. /// echo '<a name="tabs"></a>';
  42.  
  43. ## +---------------------------------------------------------------------------+
  44. ## | 3. Adding tabs:                                                           |
  45. ## +---------------------------------------------------------------------------+
  46. ## *** add tabs
  47. ## arguments:
  48. ## arg #1 - tab's caption
  49. ## arg #2 - file associated with this tab (optional)
  50. ## arg #3 - icon associated with this tab (optional)
  51. ## arg #4 - tab's tooltip
  52. ## Example 1: $tabs->AddTab("Title");
  53. ## Example 2: $tabs->AddTab("Title", "text.txt");
  54. ## Example 3: $tabs->AddTab("Title", "text.txt", "icon.gif");
  55. ## Example 4: $tabs->AddTab("Title", "text.txt", "icon.gif", "tooltip");
  56.  
  57. $son = $tabs->AddTab("Son's Title #1");
  58. $son2 = $tabs->AddTab("Son's Title #2");
  59. $grandson1=$son->AddTab("Grandson's Title #1");
  60. $grandson2=$son->AddTab("Grandson's Title #2", "examples/code.php");
  61.  
  62. ## *** associate a tab with HTML code snippet:
  63. /// $grandson1->SetInnerHTML("<b><i><span onclick='alert(\"How do you do?\")'>HTML</span></i> code snippet</b>");
  64. ## *** open a tab in a new window
  65. /// $grandson2->OpenNewWindow(true);
  66. ## *** set a tooltip for a tab
  67. /// $son->SetTooltip("Child tab's tooltip");
  68.  
  69. ## +---------------------------------------------------------------------------+
  70. ## | 4. Display Settings:                                                      |
  71. ## +---------------------------------------------------------------------------+
  72. ## *** set container's width
  73. ## *** for example "200px" or "40%" or "auto" (default)
  74. /// $tabs->SetWidth("200px");
  75. ## *** set container's height
  76. ## *** for example "200px" or "auto" (default)
  77. /// $tabs->SetHeight("200px");
  78.  
  79. ## +---------------------------------------------------------------------------+
  80. ## | 5. Disabling Tabs:                                                        |
  81. ## +---------------------------------------------------------------------------+
  82. /// $grandson2->Disable();
  83.  
  84. ## +---------------------------------------------------------------------------+
  85. ## | 6. Choosing tabs which will be selected by default:                       |
  86. ## +---------------------------------------------------------------------------+
  87. /// $tabs->SetDefaultTab($son);
  88. /// $son->SetDefaultTab($grandson2);
  89.  
  90. ## +---------------------------------------------------------------------------+
  91. ## | 7. Draw Tabs:                                                             |
  92. ## +---------------------------------------------------------------------------+
  93. $tabs->Display();
  94.    
  95. ?>