[TYPO3-mvc] extbase / fluid :: how to add an alphabetical filter/pager to list view?

Frank Krüger fkrueger-ml at mp-group.net
Thu Nov 3 11:39:27 CET 2011


Hi,

sorry for being late.
In short:

Create an alphabetical list with the capitals linked to a form submit via
the onclick-attribut:
<a href="berater/detailsuche.html#"
onclick="$('#capital').val('A');$('.frm-filter').submit();">A</a>&nbsp;&nbsp
;
<a href="berater/detailsuche.html#"
onclick="$('#capital').val('B');$('.frm-filter').submit();">B</a>&nbsp;&nbsp
;
...

The form' s action is set to the filterAction in the controller:

/**
 * Filter action for this controller.
 *
 * @return string The rendered view
 */
public function filterAction() {

  // *** look up if we have filter values
  if($this->request->hasArgument('filter')) {
    $filter = $this->request->getArgument('filter');
    $this->view->assign('filter', $filter);
    $rechtsanwaelte = $this->rechtsanwaelteRepository->findByFilter($filter,
intval($this->settings['raStoragePid']));
    $this->view->assign('rechtsanwaelte', $rechtsanwaelte);
  }
}

Now you need the 'findByFilter'-function in your repository

/**
 * Finds rechtsanwaelte by given filter parameter
 *
 * @param array $filter
 * @param integer $pagepid
 * @return array rechtsanwaelte
 */
 public function findByFilter($filter, $pagepid) {

   // *** create query
  $query = $this->createQuery();
  $query->getQuerySettings()->setRespectStoragePage(FALSE);
		
   // *** filter constraints
  $constraints = array();
  array_push($constraints, $query->equals('pid', $pagepid));

  // *** search
  if($filter['searchword']) {
   ...
  }

  // *** filter
  if(!empty($filter['capital'])) {
    array_push($constraints, $query->like('lastName',
urldecode($filter['capital']).'%'));
  }

 ...

  // *** set matching constrains if they are not empty
  if(!empty($constraints)) {
    $query->matching($query->logicalAnd($constraints));
  }

  // *** return query
  return $query->execute();
}

That's it.

HTH, Frank


-----Ursprüngliche Nachricht-----
Von: typo3-project-typo3v4mvc-bounces at lists.typo3.org
[mailto:typo3-project-typo3v4mvc-bounces at lists.typo3.org] Im Auftrag von
Roland
Gesendet: Dienstag, 1. November 2011 10:59
An: typo3-project-typo3v4mvc at lists.typo3.org
Betreff: Re: [TYPO3-mvc] extbase / fluid :: how to add an alphabetical
filter/pager to list view?

aah, i see. interesting solution. not exactly what i was looking for, but
maybe helpful anyway!
_______________________________________________
TYPO3-project-typo3v4mvc mailing list
TYPO3-project-typo3v4mvc at lists.typo3.org
http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc



More information about the TYPO3-project-typo3v4mvc mailing list