Sortierung in default.php

  • Grazioli
  • Autor
  • Offline
  • Premium Mitglied
  • Premium Mitglied
Mehr
24 März 2010 20:41 #25423 von Grazioli
Sortierung in default.php wurde erstellt von Grazioli
Hallo,

ich habe eine solche default.php in meiner Komp.

Ich möchte gerne in den Spalten eine Sortierung einbauen.
Code:
<?php ## Check if the file is included in the Joomla Framework defined('_JEXEC') or die ('No Acces to this file!'); ## Required helper for showing extra info (not stored in DB). require_once(JPATH_COMPONENT.DS.'helper'.DS.'mishelper.php'); ## Setup the toolbars. JToolBarHelper::title( JText::_( 'MISSION OVERVIEW' ) ); JToolBarHelper::publish(); JToolBarHelper::unpublish(); JToolBarHelper::editListX(); JToolBarHelper::addNew(); JToolBarHelper::deleteList(); ?> <form action = "index.php" method="POST" name="adminForm"> <table class="adminlist" width="100%"> <thead> <tr> <th width="2%" valign="middle"><input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count($this->items); ?> ) ;" /></th> <th class="title" width="183"><div align="left"> <?php echo JHTML::_('grid.sort', 'MISSION MISSION', 'c.modeltype', $this->filter_order_Dir, $this->filter_order); ?></div></th> <th class="title" width="71"> <?php echo JHTML::_('grid.sort', 'MISSION ONDATE', 'c.ondate', $this->filter_order_Dir, $this->filter_order); ?></th> <th width="76"> <?php echo JHTML::_('grid.sort', 'MISSION OFFDATE', 'c.offdate', $this->filter_order_Dir, $this->filter_order); ?></th> <th width="79"> <?php echo JHTML::_('grid.sort', 'MISSION CATEGORY', 'd.catname', $this->filter_order_Dir, $this->filter_order); ?></th> <th width="73"><?php echo JText::_( 'ADDED' ); ?></th> <th width="76"><?php echo JText::_( 'UPDATED' ); ?></th> <th width="81"><?php echo JText::_( 'HITS' ); ?></th> <th width="71"><?php echo JText::_( 'PUBLISHED' ); ?></th> </tr> </thead> <?php $k = 0; for ($i = 0, $n = count($this->items); $i < $n; $i++ ){ ## Give give $row the this->item&#91;$i&#93; $row = &$this->items&#91;$i&#93;; $published = JHTML::_('grid.published', $row, $i ); $checked = JHTML::_('grid.id', $i, $row->misid ); ## Making links for redirection and deletion. $link = 'index.php?option=' .$option. '&task=edit&cid='.$row->misid; ?> <tr class="<?php echo "row$k"; ?>"> <td valign="middle"><div align = "center"><?php echo $checked; ?></div></td> <td><a href = "<?php echo $link; ?>"><?php echo $row->modeltype; ?> <small><br> <?php echo $row->summary; ?></small></td> <td><div align="center"><?php echo $row->ondate; ?></div></td> <td><div align="center"><?php echo $row->offdate; ?></div></td> <td style="color: #000; background-color:#<?php echo $row->color; ?>;"><div align="center"><?php echo $row->catname; ?></div></td> <td><div align="center"><?php echo date ("d-m-Y", strtotime($row->added)); ?></div></td> <td><div align="center"><?php echo date ("d-m-Y", strtotime($row->updated)); ?></div></td> <td><div align="center"><?php echo $row->hits; ?></div></td> <td><div align="center"><?php echo $published; ?></div></td> </tr> <?php $k=1 - $k; } ?> </table> <input type="hidden" name="filter_order" value="<?php echo $this->filter_order; ?>" /> <input type="hidden" name="filter_order_Dir" value="<?php echo $this->filter_order_Dir; ?>" /> <input name = "option" type="hidden" value="<?php echo $option; ?>" /> <input name = "task" type="hidden" value="" /> <input name = "boxchecked" type="hidden" value="0"/> <input name = "controller" type="hidden" value="mission"/> <table width="100%" align="center" class="adminlist"> <tfoot> <tr> <td colspan="7"><div align="center"><?php echo $this->pagination->getListFooter(); ?></div></td> </tr> </tfoot> </table> </form>
Was habe ich falsch oder nicht eingebaut? Das java wird erkannt und es reagiert, aber ich kann die Spalten nicht Sortieren! Schön wäre noch mit einem Pfeil, wie bei den Beiträgen!

Danke und Gruss
Grazioli

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Mehr
24 März 2010 21:18 #25425 von Tribal6
Tribal6 antwortete auf Re: Sortierung in default.php
Hi Grazioli

Werden die Sortierfilter im Model ausgelesen, in die Session geschrieben, und bei der Querybildung berücksichtigt?
(und in der View, beim erneuten Anzeigen dann wieder ausgelesen?)

Tue das, was du kannst, mit dem was du hast, da wo du bist.

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

  • Grazioli
  • Autor
  • Offline
  • Premium Mitglied
  • Premium Mitglied
Mehr
27 März 2010 08:10 #25480 von Grazioli
Grazioli antwortete auf Re: Sortierung in default.php
Hallo,

ich habe das hier gefunden --ALTER LINK WURDE ENTFERNT--

Kann ich nach dem gehen?

Gruss Grazioli

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

  • Grazioli
  • Autor
  • Offline
  • Premium Mitglied
  • Premium Mitglied
Mehr
28 März 2010 19:54 #25520 von Grazioli
Grazioli antwortete auf Re: Sortierung in default.php
Hi,

ich habe jetzt schon mehrere Versuche gestrartet, aber bekamm leider nichts hin! Ich habe sogar die halloworld03 angeschaut, und nach dieser habe ich auch kein Erfolg! ??? ? :'( '(

view.html.php
Code:
function display($tpl = null) { ## If we want the add/edit form.. if($this->getLayout() == 'form') { $this->_displayForm($tpl); return; } global $mainframe, $option; $db = JFactory::getDBO(); //DEVNOTE:give me ordering from request $filter_order = $mainframe->getUserStateFromRequest( $context.'filter_order', 'filter_order', 'ordering' ); $filter_order_Dir = $mainframe->getUserStateFromRequest( $context.'filter_order_Dir', 'filter_order_Dir', '' ); //DEVNOTE:remember the actual order and column $lists&#91;'order'&#93; = $filter_order; $lists&#91;'order_Dir'&#93; = $filter_order_Dir; ## Making the query for getting the currency from the config table $sql = 'SELECT currency, offdate FROM #__management_config WHERE id = 1'; $db->setQuery($sql); $data = $db->loadObject(); ## Model is defined in the controller $model =& $this->getModel(); ## Getting the items into a variable $items =& $this->get('list'); ## Getting the pagination thing :-) $pagination = $this->get( 'Pagination' ); $this->assignRef('items', $items); $this->assignRef( 'pagination' , $pagination); $this->assignRef('items', $items); $this->assignRef('data', $data); parent::display($tpl); }
models/mission.php
Code:
class FreeModelMission extends JModel { ## Empty data variabele var $_data = null; var $_id = null; var $_ordering = null; var $_orderby = null; var $_total; var $_pagination; function __construct() { parent::__construct(); global $mainframe, $option; $config = JFactory::getConfig(); ## Get the pagination request variables $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' ); $limitstart = $mainframe->getUserStateFromRequest( 'products.limitstart', 'limitstart', 0, 'int' ); ## In case limit has been changed, adjust limitstart accordingly $limitstart = ($limit != 0 ? (floor($limitstart / $limit) * $limit) : 0); $this->setState('limit', $limit); $this->setState('limitstart', $limitstart); $this->id = JRequest::getInt('cid', 0); $this->_id = JRequest::getInt('cid', 0); } function _buildContentOrderBy() { global $mainframe, $context; //DEVNOTE:give me ordering from request $filter_order = $mainframe->getUserStateFromRequest( $context.'filter_order', 'filter_order', 'misid' ); $filter_order_Dir = $mainframe->getUserStateFromRequest( $context.'filter_order_Dir', 'filter_order_Dir', '' ); if ($filter_order == 'c.misid'){ $orderby = ' ORDER BY c.misid, c.hits '; } else { $orderby = ' ORDER BY '.$filter_order.' '.$filter_order_Dir.' , c.misid, c.hits '; } return $orderby; } function getList() { if (empty($this->_data)) { $db = JFactory::getDBO(); $orderby = $this->_buildContentOrderBy(); ## Making the query for showing all the mission in list function $sql = 'SELECT a.fatname, b.vatname, c.*, d.catname, d.color FROM #__management_person AS a, #__management_free AS b, #__management_mission AS c, #__management_category AS d ' . ' WHERE c.fatid = a.fatid ' . ' AND c.vatid = b.vatid ' . ' AND c.catid = d.catid' . $orderby;; $db->setQuery($sql, $this->getState('limitstart'), $this->getState('limit' )); $this->data = $db->loadObjectList(); } return $this->data; }
default.php
Code:
<script language="javascript" type="text/javascript"> function tableOrdering( order, dir, task ) { var form = document.adminForm; form.filter_order.value = order; form.filter_order_Dir.value = dir; document.adminForm.submit( task ); } </script>
Code:
<?php echo JHTML::_('grid.sort', 'ID#', 'id', $this->lists&#91;'order_Dir'&#93;, $this->lists&#91;'order'&#93;); ?></th> <th width="33%"><div align="left"> <?php echo JHTML::_('grid.sort', 'MMISSION', 'type', $this->lists&#91;'order_Dir'&#93;, $this->lists&#91;'order'&#93;); ?></div></th> <th width="10%"> <?php echo JHTML::_('grid.sort', 'ONDATE', 'ondate', $this->lists&#91;'order_Dir'&#93;, $this->lists&#91;'order'&#93;); ?></th> <th width="10%"> <?php echo JHTML::_('grid.sort', 'OFFDATE', 'offdate', $this->lists&#91;'order_Dir'&#93;, $this->lists&#91;'order'&#93;); ?></th> <th width="20%"> <?php echo JHTML::_('grid.sort', 'CATEGORY', 'catname', $this->lists&#91;'order_Dir'&#93;, $this->lists&#91;'order'&#93;); ?></th>

Bitte um Hilfe!

Gruss Grazioli

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Mehr
29 März 2010 21:46 #25533 von Tribal6
Tribal6 antwortete auf Re: Sortierung in default.php
Hi Grazioli

Was genau geht denn nicht?

Also ich vermute mal, das in der default.php nix in $this->lists ist, weil in der view.html.php ein
$this->assignRef('lists', $lists);
fehlt (oder ich hab's übersehen). Um zu checken, was für Werte in welcher Variablen ist, ist die Erweiterung 'JDump' noch recht nützlich, und nur zu empfehlen ;)

Tue das, was du kannst, mit dem was du hast, da wo du bist.

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

  • Grazioli
  • Autor
  • Offline
  • Premium Mitglied
  • Premium Mitglied
Mehr
30 März 2010 19:36 #25544 von Grazioli
Grazioli antwortete auf Re: Sortierung in default.php
Hallo,

Tribal6 schrieb: $this->assignRef('lists', $lists);
fehlt ;)


genau das wars!

Super und Danke
Grazioli

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Moderatoren: Tribal6RePaoDragonlordChris Hoefligerpascaleadiheutschi.ch
Powered by Kunena Forum

Joomla! Verband Schweiz - Mitglied werden