Ver Mensaje Individual
  #1 (permalink)  
Antiguo 27/05/2011, 15:04
caguayo
 
Fecha de Ingreso: abril-2011
Mensajes: 41
Antigüedad: 13 años, 1 mes
Puntos: 0
No consigo cambiar de tab

Hola a todos:

Quiero montar en un pequeño sitio unos tabs pero no consigo que este código que encontré en internet conmute y muestre el contenido de los demás tabs. Siempre está activo el primer tabs. Cuando doy un click sobre cualquiera de los tabs va hacia un enlace que está fuera y nunca me activa ese tab y más que todo necesito que muestre el contenido (body) del tab correspondiente.

¿Cuál es la parte del código que determina la conmutación entre los tabs?

Para no hacer muy largo este hilo no he colocado el archivo .css, el cuál muestra correctamente los tabs.

El archivo Static_Tabstrip.php

Código PHP:
Ver original
  1. <?php
  2.     /**
  3.     * o------------------------------------------------------------------------------o
  4.     * | This package is licensed under the Phpguru license. A quick summary is       |
  5.     * | that for commercial use, there is a small one-time licensing fee to pay. For |
  6.     * | registered charities and educational institutes there is a reduced license   |
  7.     * | fee available. You can read more  at:                                        |
  8.     * |                                                                              |
  9.     * |                  http://www.phpguru.org/static/license.html                  |
  10.     * o------------------------------------------------------------------------------o
  11.     *
  12.     */
  13.  
  14.     /**
  15.     * Produces a tab strip
  16.     *
  17.     * NB: Don't forget the CSS styles
  18.     *
  19.     * @param array $tabs Multi dimensional array of tabs. First dimension is
  20.     *                    numerically indexed, second has the following keys:
  21.     *                     o link   -  The link used
  22.     *                     o name   -  The text used inside the link which the user sees
  23.     *                     o active -  Whether this tab is active or not. Naturally only
  24.     *                                 one tab should have this set to true...
  25.     */
  26.     function PrintTabStrip($tabs, $leader = null)
  27.     {
  28.         ?>
  29.             <div class="tabstrip">
  30.                 &nbsp;
  31.                 <?foreach($tabs as $t):?>
  32.                     <div class="tabstrip_tab <?=($t['active'] ? 'active' : '')?>" id="<?=$t['id']?>">
  33.                         <?if(!$t['active']):?>
  34.                             <img src="images/tab_tl.png" style="position: absolute; top: -1px; left: -1px" width="5" height="5" />
  35.                             <img src="images/tab_tr.png" style="position: absolute; top: -1px; right: -1px" width="5" height="5" />
  36.                         <?else:?>
  37.                             <img src="images/tab_active_tl.png" style="position: absolute; top: -1px; left: -1px" width="5" height="5" />
  38.                             <img src="images/tab_active_tr.png" style="position: absolute; top: -1px; right: -1px" width="5" height="5" />
  39.                         <?endif?>
  40.                        
  41.                         <?if(!empty($t['link'])):?><a href="<?=$t['link']?>" <?if(!empty($t['mouseover'])):?>onmouseover="window.status = '<?=$t['mouseover']?>'; return true" onmouseout="window.status = ''"<?endif?>><?=$t['name']?></a><?else:?><?=$t['name']?><?endif?>
  42.                     </div>
  43.                 <?endforeach?>
  44.                 &nbsp;
  45.             </div>
  46.         <?php
  47.     }
  48. ?>



Código PHP:
Ver original
  1. <?php
  2.   /**
  3.   * Include the tabstrip code
  4.   */
  5.   require_once('Static_Tabstrip.php');
  6.  
  7.   /**
  8.   * Define the tabs by using a two dimensional array
  9.   */
  10.   $tabs = array(
  11.          array('id' => 'tab_1', 'name' => 'First tab', 'active' => empty($_GET['tab']), 'link' => 'example.php', 'mouseover' => 'Visit Google!'),
  12.          array('id' => 'tab_2', 'name' => 'Second', 'active' => !empty($_GET['tab']) && $_GET['tab'] === '2', 'link' => 'example.php?tab=2', 'mouseover' => 'Or not...'),
  13.          array('id' => 'tab_3', 'name' => 'Third (disabled)', 'active' => false)
  14.          );
  15.  
  16.   PrintTabStrip($tabs);
  17. ?>

Código HTML:
Ver original
  1. <div class="tab_body">
  2.   <?if(empty($_GET['tab'])):?>
  3.     <h1>Some content</h1>
  4.  
  5.     <p>
  6.       Put the main content in here
  7.     </p>
  8.   <?elseif($_GET['tab'] == 2):?>
  9.     <h1>More content</h1>
  10.  
  11.     <p>
  12.       Put more content in here. Use seperate files for better organisation.
  13.     </p>
  14.   <?endif?>
  15. </div>


Muchas gracias me pueden ayudar?, porfa