Russian TYPO3 community Форум больше не используется. Присоединяйтесь к каналу #community-ru в Slack for TYPO3 community  

Вернуться   Russian TYPO3 community > Тематические форумы > Разработка расширений / TYPO3 extension development

Ответ
 
Опции темы Опции просмотра
Старый 15.10.2008, 18:37   #1
SoulBurn
Новенький
 
Аватар для SoulBurn
 
Регистрация: 09.09.2008
Сообщений: 21
Отправить сообщение для SoulBurn с помощью ICQ
Question Сортировка в таблице

class.tx_test_pi1.php
PHP код:
<?php
require_once(PATH_tslib.'class.tslib_pibase.php');
class 
tx_test_pi1 extends tslib_pibase {
    var 
$prefixId      'tx_test_pi1';        // Same as class name
    
var $scriptRelPath 'pi1/class.tx_test_pi1.php';    // Path to this script relative to the extension dir.
    
var $extKey        'test';    // The extension key.
    
var $pi_checkCHash true;
    var 
$order;
    function 
main($content,$conf)    {

        
$this->conf=$conf;
        
$this->pi_setPiVarDefaults();
        
$this->pi_loadLL();

        
$content $this->displayList();

        return 
$this->pi_wrapInBaseClass($content);
    }


    function 
displayList($content,$conf)    {

        if (isset(
$this->piVars['age'])) $this->order 'age';

        
$this->templateCode $this->cObj->fileResource('EXT:test/res/test_template.html');

        
$template = array();
        
$template['total'] = $this->cObj->getSubpart($this->templateCode,'###TEST_TEMPLATE###');
        
$template['singlerow'] = $this->cObj->getSubpart($template['total'],'###SINGLEROW###');
        
$template['row'] = $this->cObj->getSubpart($template['singlerow'],'###ITEM###');
        
$template['row_alt'] = $this->cObj->getSubpart($template['singlerow'],'###ITEM_ALT###');

        
$marker = array();
        
$marker['###TEST_HID###']    = $this->pi_getLL('id');
        
$marker['###TEST_HNAME###']    = $this->pi_getLL('name');
        
$marker['###TEST_HLNAME###']= $this->pi_getLL('lname');
          
$marker['###TEST_HAGE###']    = $this->pi_getLL('age');

        
$res $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid,name,last_name,age','tx_test_db','',$this->order);

          
$switch_row 0;
        while (
$row $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {

               
$marker['###TEST_ID###']    = $row['uid'];
               
$marker['###TEST_NAME###']    = $row['name'];
              
$marker['###TEST_LNAME###']    = $row['last_name'];
              
$marker['###TEST_AGE###']    = $row['age'];

            
$switch_row $switch_row 1;
            if(
$switch_row) {
                
$content_item .= $this->cObj->substituteMarkerArrayCached($template['row'], $marker);
            } else {
                
$content_item .= $this->cObj->substituteMarkerArrayCached($template['row_alt'], $marker);
            }
        }

        
$subpartArray['###SINGLEROW###'] = $content_item;

        
$content $this->cObj->substituteMarkerArrayCached($template['total'],$marker,$subpartArray);

        return 
$content;
    }

}

if (
defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/test/pi1/class.tx_test_pi1.php'])    {
    include_once(
$TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/test/pi1/class.tx_test_pi1.php']);
}

?>
test_template.html
Код HTML:
<!-- ###TEST_TEMPLATE### begin -->
<table width=100% class="table">
	<tr class="table-header"> 
   		<th>###TEST_HID###</th>
      <th>###TEST_HNAME###</th>
      <th>###TEST_HLNAME###</th>
      <th>
         <input type="submit" value="###TEST_HAGE###" class="tx-test-button" name="tx_test_pi1[age]" />
       </th>
	</tr>
	<!-- ###SINGLEROW### -->
   <!-- ###ITEM### -->
	<tr class="table-body1">
		<th>###TEST_ID###</th>
      <th>###TEST_NAME###</th>
      <th>###TEST_LNAME###</th>
      <th>###TEST_AGE###</th>
	</tr>
	<!-- ###ITEM### -->
  <!-- ###ITEM_ALT### -->
	<tr class="table-body2">
		<th>###TEST_ID###</th>
      <th>###TEST_NAME###</th>
      <th>###TEST_LNAME###</th>
      <th>###TEST_AGE###</th>
	</tr>
	<!-- ###ITEM_ALT### -->
	<!-- ###SINGLEROW### -->
	<tr class="table-footer">
		<th></th>
      <th></th>
      <th></th>
      <th></th>
	</tr>
</table>	
<!-- ###TEST_TEMPLATE### end -->
надо, чтобы при нажатии на кнопку (<input type="submit" value="###TEST_HAGE###" class="tx-test-button" name="tx_test_pi1[age]" />) сортировало таблицу по выбраному полю... чего-то не получается...

подскажите где не так плз...
__________________
SoulBurn вне форума   Ответить с цитированием
Старый 16.10.2008, 19:50   #2
SoulBurn
Новенький
 
Аватар для SoulBurn
 
Регистрация: 09.09.2008
Сообщений: 21
Отправить сообщение для SoulBurn с помощью ICQ
Exclamation Решение

Вобщем помог всемогущий гугл...
Подключил вот этот ява-скрипт этой:
PHP код:
$GLOBALS['TSFE']->additionalHeaderData['test'] .= '<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath('test').'res/scripts/sorttable.js"></script>'.chr(10); 
командой (дописывает строчку в хедер)... Делать в PHP нет времени

ВАЖНО!!!
<table class="sortable"> обязательно sortable, иначе скрипт не будет работать (разбираться в Яве лень )

З.Ы. И всё-таки хотельсь бы увидеть решение на PHP (не дай Бог клиент захочет раскрасить строки зеброй )

З.З.Ы. Исходники немного поменялись поэтому выкладываю снова

class.tx_test_pi1.php
PHP код:
<?php
require_once(PATH_tslib.'class.tslib_pibase.php');

class 
tx_test_pi1 extends tslib_pibase {
    var 
$prefixId      'tx_test_pi1';        // Same as class name
    
var $scriptRelPath 'pi1/class.tx_test_pi1.php';    // Path to this script relative to the extension dir.
    
var $extKey        'test';    // The extension key.
    
var $pi_checkCHash true;
    var 
$eventUid;

    function 
main($content,$conf)    {

        
$this->conf=$conf;
        
$this->pi_setPiVarDefaults();
        
$this->pi_loadLL();
        
$this->pi_USER_INT_obj=1;

        
$content $this->displayList();

        return 
$this->pi_wrapInBaseClass($content);
    }


    function 
displayList($content,$conf)    {

        
$this->templateCode $this->cObj->fileResource('EXT:test/res/test_template.html');
        
$GLOBALS['TSFE']->additionalHeaderData['test'] .= '<script type="text/javascript" src="'.t3lib_extMgm::siteRelPath('test').'res/scripts/sorttable.js"></script>'.chr(10);
        
$GLOBALS['TSFE']->additionalHeaderData['test'] .= '<link rel="stylesheet" type="text/css" href="'.t3lib_extMgm::siteRelPath('test').'res/css/test.css" />'.chr(10);

        
$template = array();
        
$template['total'] = $this->cObj->getSubpart($this->templateCode,'###TEST_TEMPLATE###');
        
$template['singlerow'] = $this->cObj->getSubpart($template['total'],'###SINGLEROW###');
        
$template['row'] = $this->cObj->getSubpart($template['singlerow'],'###ITEM###');
        
$template['row_alt'] = $this->cObj->getSubpart($template['singlerow'],'###ITEM_ALT###');

        
$marker = array();
        
$marker['###TEST_HID###']    = $this->pi_getLL('id');
        
$marker['###TEST_HNAME###']    = $this->pi_getLL('name');
        
$marker['###TEST_HLNAME###']= $this->pi_getLL('lname');
          
$marker['###TEST_HAGE###']    = $this->pi_getLL('age');
        
$marker['###TEST_ACTION###']    = $this->pi_getPageLink($GLOBALS[TSFE]->id);

        
$res $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid,name,last_name,age','tx_test_db','');

          
$switch_row 0;
        while (
$row $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {

               
$marker['###TEST_ID###']    = $row['uid'];
               
$marker['###TEST_NAME###']    = $row['name'];
              
$marker['###TEST_LNAME###']    = $row['last_name'];
              
$marker['###TEST_AGE###']    = $row['age'];

>
substituteMarkerArrayCached($template['row'], $marker);

        }
        
$subpartArray['###SINGLEROW###'] = $content_item;

        
$content .= $this->cObj->substituteMarkerArrayCached($template['total'],$marker,$subpartArray);

        return 
$content;
    }
}

if (
defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/test/pi1/class.tx_test_pi1.php'])    {
    include_once(
$TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/test/pi1/class.tx_test_pi1.php']);
}

?>
test_template.html
Код HTML:
<!-- ###TEST_TEMPLATE### begin -->
<table class="sortable">
	<thead>
    <tr class="table-header"> 
      <th>###TEST_HID###</th>
      <th>###TEST_HNAME###</th>
      <th>###TEST_HLNAME###</th>
      <th>###TEST_HAGE###</th>
    </tr>
	</thead>
	<tbody>
	<!-- ###SINGLEROW### -->
	<!-- ###ITEM### -->
    <tr class="table-body1">
      <th>###TEST_ID###</th>
      <th>###TEST_NAME###</th>
      <th><!-- ###LINK### -->###TEST_LNAME###<!-- ###LINK### --></th>
      <th>###TEST_AGE###</th>
    </tr>
    <!-- ###ITEM### -->
    <!-- ###ITEM_ALT### -->
    <tr class="table-body2">
      <th>###TEST_ID###</th>
      <th>###TEST_NAME###</th>
      <th><!-- ###LINK### -->###TEST_LNAME###<!-- ###LINK### --></th>
      <th>###TEST_AGE###</th>
    </tr>
  <!-- ###ITEM_ALT### -->
  <!-- ###SINGLEROW### -->
  </tbody>
  <tfoot>
    <tr class="table-footer">
      <th><a href="index.php?id=132&amp;tx_julleevents_pi1[showUid]=1&amp;cHash=6739979ac8" >Click</th>
      <th></th>
      <th></th>
      <th></th>
    </tr>
  </tfoot>	
</table>	
<!-- ###TEST_TEMPLATE### end -->
</body>
</html>
__________________
SoulBurn вне форума   Ответить с цитированием
Ответ


Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB code is Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.

Быстрый переход

Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Mode 1, Mode 2 в таблице порождаемой кикстартером filippoff TypoScript практикум 0 14.01.2007 14:01
Сортировка в tt_products Arhnt Магазины и каталоги для TYPO3 2 05.12.2006 07:51
Сортировка продуктов в tt_products filippoff Магазины и каталоги для TYPO3 0 22.08.2006 17:05
Картинка как фон в таблице stoun Общие вопросы 2 04.12.2005 16:40
Тег H1 в таблице stoun HTMLArea, RTE, tinymce_rte и другие визуальные редакторы 0 21.04.2005 14:27


Часовой пояс GMT +4, время: 17:29.


Работает на vBulletin® версия 3.8.1.
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Перевод: zCarot

Хостинг и техническая поддержка: TYPO3 Лаборатория