[TYPO3] kickstarter orderby date

Bernhard Kraft kraftb at kraftb.at
Mon Jul 31 10:17:03 CEST 2006


Tim Boesenkool wrote:

> I have modified everything else I need, and I can get the column heads
> to sort correctly when clicked, but I can't get the initial page to
> load correctly after a new record is added. It always defaults to the
> bottom of the list.

I can't believe you can sort the list anyhow when you have this line commented
out:

>              // $this->internal['orderByList']='file_date';

You should set "orderByList" to a comma separated list of all fields for which you would like
to allow sorting ...

And here:

>                // Initializing the query parameters:
>            list($this->internal['orderBy'],$this->internal['descFlag']) = explode(':',$this->piVars['sort']);

it get's initalized after which field to sort ... $this->piVars['sort'] will contain a string like:
"title:1" which means that it should get sorted after the title field DESCending .... but this will
only happen if you hvae "orderByList" set to "whateverfield,title,whateverfield2" .... meaning title
must occur in the orderByList.

The problem when you view the page for the first time is that $this->piVars['sort'] is not intialized.

The easiest thing is to initalize it directly via the $this->piVars['sort'] variable. So just add the
lines:

if (!isset($this->piVars['sort'])) {
  $this->piVars['sort'] = 'myDefaultOrderField:1';	// 1== Descending, 0 == ascending
}

before the line:

>            list($this->internal['orderBy'],$this->internal['descFlag']) = explode(':',$this->piVars['sort']);



greets,
Bernhard
-- 
----------------------------------------------------------------------
"Freiheit ist immer auch die Freiheit des Andersdenkenden"
Rosa Luxemburg, 1871 - 1919
----------------------------------------------------------------------
[[ http://think-open.at | Open source company ]]



More information about the TYPO3-english mailing list