+33 3 83 56 65 26 +33 6 87 42 95 30 Cette adresse e-mail est protégée contre les robots spammeurs. Vous devez activer le JavaScript pour la visualiser. Lun-Ven : 9.00 à 17.00

Colonne triable MVC Composent

More
14 years 4 months ago - 14 years 4 months ago #28935 by smiley88
Bonjour à vous,

Cela fait deux jours que j'essaye que essaye de rapatrier mes donnée de ma table SQL dans des colonnes triables mais malgré quelque tutoriel trouvé sur le net aucun ne marche correctement.

docs.joomla.org/Adding_sortab...in_a_component : erreur au niveau de l'instruction ORDER BY

forum.joomla.org/viewtopic.php?f=642&t=615125

J'arrive à afficher mes données mais le problème se situe au niveau de ma requête SQL car ma variable "filter_order" ressoie correctement le nom de colonne que ce soit au niveau du template, de ma vue ou de mon model.

Mon affichage :
Code:
<?php if($this->items) : ?> <form id="adminForm" action="<?php echo JRoute::_( 'index.php' );?>" method="post" name="adminForm"> <table> <tr> <th><?php echo JHTML::_( 'grid.sort', 'Date', 'a.date_gain', $this->sortDirection, $this->sortColumn); ?></th> <th><?php echo JHTML::_( 'grid.sort', 'Prenom', 'a.prenom', $this->sortDirection, $this->sortColumn); ?></th> <th><?php echo JHTML::_( 'grid.sort', 'Nom', 'a.nom', $this->sortDirection, $this->sortColumn); ?></th> <th><?php echo JHTML::_( 'grid.sort', 'CP et ville', 'a.cp_et_ville', $this->sortDirection, $this->sortColumn); ?></th> <th><?php echo JHTML::_( 'grid.sort', 'Cadeau', 'a.nom_du_cadeau', $this->sortDirection, $this->sortColumn); ?></th> </tr> <?php foreach ($this->items as $item) :?> <tr> <th><?php echo $item->date_gain; ?></th> <th><?php echo $item->prenom; ?></th> <th><?php echo $item->nom; ?></th> <th><?php echo $item->cp_et_ville; ?></th> <th><?php echo $item->nom_du_cadeau; ?></th> </tr> <?php endforeach; ?> <div class="pagination"> <?php if ($this->params->def('show_pagination_results', 1)) : ?> <p class="counter"> <?php echo $this->pagination->getPagesCounter(); ?> </p> <?php endif; ?> <?php echo $this->pagination->getPagesLinks(); ?> </div> <?php //echo $this->sortColumn; ?> <input type="hidden" name="filter_order" value="<?php echo $this->sortColumn; ?>" /> <input type="hidden" name="filter_order_Dir" value="<?php echo $this->sortDirection; ?>" /> <table> </form> <?php endif; ?>

Ma vue :
Code:
class GagnantsmagnumViewGagnants extends JView { protected $items; protected $pagination; protected $state; protected $params; /** * Display the view */ public function display($tpl = null) { $app = JFactory::getApplication(); $this->state = $this->get('State'); $this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); $this->params = $app->getParams('com_gagnantsmagnum'); // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } $this->sortDirection = $this->state->get('filter_order_Dir'); $this->sortColumn = $this->state->get('filter_order'); //echo $this->sortColumn; $this->_prepareDocument(); parent::display($tpl); } }

Mon modele
Code:
class GagnantsmagnumModelGagnants extends JModelList { /** * Constructor. * * @param array An optional associative array of configuration settings. * @see JController * @since 1.6 */ public function __construct($config = array()) { parent::__construct($config); } /** * Method to auto-populate the model state. * * Note. Calling getState in this method will result in recursion. * * @since 1.6 */ //$ordering = null, $direction = null protected function populateState() { // Initialise variables. $app = JFactory::getApplication(); // List state information $limit = $app->getUserStateFromRequest('global.list.limit', 'limit', $app->getCfg('list_limit')); $this->setState('list.limit', $limit); $limitstart = JRequest::getVar('limitstart', 0, '', 'int'); $this->setState('list.start', $limitstart); ///////// // AJOUT //////// $filter_order = JRequest::getCmd('filter_order','a.date_gain'); $filter_order_Dir = JRequest::getCmd('filter_order_Dir','DESC'); //echo $filter_order; $this->setState('filter_order', $filter_order); $this->setState('filter_order_Dir', $filter_order_Dir); //echo $this->setState('filter_order'); // List state information. parent::populateState(); } /** * Build an SQL query to load the list data. * * @return JDatabaseQuery * @since 1.6 */ protected function getListQuery() { // Create a new query object. // echo $filter_order; // echo $filter_order_Dir; //$db = $this->getDbo(); $db = JFactory::getDbo(); $query = $db->getQuery(true); // Select the required fields from the table. $query->select( $this->getState( 'list.select', 'a.*' ) ); $query->from('`#__gagnantsmagnum_gagnants` AS a'); // Filter by published state $published = $this->getState('filter.state'); if (is_numeric($published)) { $query->where('a.state = '.(int) $published); } else if ($published === '') { $query->where('(a.state IN (0, 1))'); } $query->order($db->getEscaped($this->getState('list.ordering', 'a.date_gain')).' '.$db->getEscaped($this->getState('list.direction', 'DESC'))); return $query; } }

Je sais sa fait beaucoup de code mais si quelqu'un veux jeter un coup d'oeil ou si vous connaissez un tutoriel qui marche !

MERCI
Last edit: 14 years 4 months ago by smiley88.

Please Connectez-vous or Create an account to join the conversation.

More
14 years 4 months ago #28956 by tramber91
Bonjour

la je peux pas t'aider au niveau de la codification php
mais pourquoi tu n'utilises pas un composant tout fait comme Fabrik qui fait la même chose

@+

Pas de support en MP sans y être invité. Merci
Merci de vous conformer aux règles du forum. Un merci, Cela fait toujours plaisir ;)
www.en-toutes-lettres.fr - Digital
The following user(s) said Thank You: smiley88

Please Connectez-vous or Create an account to join the conversation.

More
14 years 4 months ago #28965 by smiley88
Merci pour cette extensions c'est tous à fait ce qu'il me fallait.

Le seul soucis c'est sa mise en place, pour charger la date afficher les donnée pas de souci.

Mais j'ai quelque soucis par exemple j'ai un menu je fais un lien vers ma liste dans le composant Fabrik pas de soucis, à cette page je lui affecte le module préinstallé mod_fabrik_list les donnée s'affiche sans soucis sauf que j'ai 2 affichage.

Le hic se situe au niveau du module quand je l'affecte à une page mais sans que celle-ci soit relié au composant la page m'affiche ERREUR 500 : Mise en page default_row introuvable.

Quelqu'un pourrait-il m’expliquer cela ? Merci :dieu

Please Connectez-vous or Create an account to join the conversation.

More
14 years 3 months ago #29056 by tramber91
Bonsoir

pas clair ton histoire
ton lien menu affiche une liste ou tu peux faire tes recherches et tri et c'est ok
pourquoi veux tu, a cette même page ajouter un module liste afin d'avoir deux listes ?

à+

Pas de support en MP sans y être invité. Merci
Merci de vous conformer aux règles du forum. Un merci, Cela fait toujours plaisir ;)
www.en-toutes-lettres.fr - Digital

Please Connectez-vous or Create an account to join the conversation.

Time to create page: 0.147 seconds

News Communautés

News sécurité