Discussion:
[TYPO3-english] extbase findAll() default_sortby
Muriel le Pair
2013-07-30 13:28:00 UTC
Permalink
Hi,

I would like findAll() to order by they default_sortby set in the TCA,
but it doesn't work.
How are you expected to sort a query in extbase?

In ext_tables.php both sortby and default_sortby have been set to the
sorting field.

'sortby' => 'sorting',
'default_sortby' => 'ORDER BY sorting',

I would expect that findAll() would use this settings, but somehow they
are ignored.

I have been looking at
http://forge.typo3.org/projects/typo3v4-mvc/wiki/Default_Orderings_and_Query_Settings_in_Repository
and
http://api.typo3.org/extbase/current/TYPO3/CMS/Extbase/Persistence/Generic/class-Typo3QuerySettings.html
but the odd thing is that I can't find any options to order by.


So in good old plain mysql: SELECT * from mytable ORDER BY sorting asc.

--
kind regards,

Muriel le Pair
Henjo Hoeksma | Stylence
2013-07-30 14:12:02 UTC
Permalink
Hi Muriel,

the link you provide to Forge explains exactly how to set defaultOrderings
in the repository.
The stuff you put in the TCA Array are pure for the Backend and Extbase
does not look there. These are two separate things.

Hope this makes it a little more clear ;-)

Kind regards,

Henjo

Problems are small because we learned how to deal with them.
Problems are big because we need to learn how to deal with them.
Hi,
I would like findAll() to order by they default_sortby set in the TCA, but
it doesn't work.
How are you expected to sort a query in extbase?
In ext_tables.php both sortby and default_sortby have been set to the
sorting field.
'sortby' => 'sorting',
'default_sortby' => 'ORDER BY sorting',
I would expect that findAll() would use this settings, but somehow they
are ignored.
I have been looking at http://forge.typo3.org/**projects/typo3v4-mvc/wiki/
**Default_Orderings_and_Query_**Settings_in_Repository<http://forge.typo3.org/projects/typo3v4-mvc/wiki/Default_Orderings_and_Query_Settings_in_Repository>and
http://api.typo3.org/extbase/**current/TYPO3/CMS/Extbase/**
Persistence/Generic/class-**Typo3QuerySettings.html<http://api.typo3.org/extbase/current/TYPO3/CMS/Extbase/Persistence/Generic/class-Typo3QuerySettings.html>but the odd thing is that I can't find any options to order by.
So in good old plain mysql: SELECT * from mytable ORDER BY sorting asc.
--
kind regards,
Muriel le Pair
______________________________**_________________
TYPO3-english mailing list
TYPO3-english at lists.typo3.org
http://lists.typo3.org/cgi-**bin/mailman/listinfo/typo3-**english<http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english>
Muriel le Pair
2013-08-01 08:25:25 UTC
Permalink
Post by Henjo Hoeksma | Stylence
the link you provide to Forge explains exactly how to set defaultOrderings
in the repository.
The stuff you put in the TCA Array are pure for the Backend and Extbase
does not look there. These are two separate things.
Hi,

I quess I'm missing something.
The link explains how to change ASC and DESC with $defaultOrderings.
But I would like to know how I can set findAll() to order on the sorting
column (kind of got the impression it is now ordering on the uid).

--
kind regards,

Muriel le Pair
Henjo Hoeksma | Stylence
2013-08-01 10:03:18 UTC
Permalink
Hi Muriel,

what about:

protected $defaultOrderings = array(
'sorting' => Tx_Extbase_Persistence_QueryInterface::ORDER_ASCENDING
);


Kind regards,

Henjo

Problems are small because we learned how to deal with them.
Problems are big because we need to learn how to deal with them.
Post by Henjo Hoeksma | Stylence
the link you provide to Forge explains exactly how to set defaultOrderings
Post by Henjo Hoeksma | Stylence
in the repository.
The stuff you put in the TCA Array are pure for the Backend and Extbase
does not look there. These are two separate things.
Hi,
I quess I'm missing something.
The link explains how to change ASC and DESC with $defaultOrderings.
But I would like to know how I can set findAll() to order on the sorting
column (kind of got the impression it is now ordering on the uid).
--
kind regards,
Muriel le Pair
______________________________**_________________
TYPO3-english mailing list
TYPO3-english at lists.typo3.org
http://lists.typo3.org/cgi-**bin/mailman/listinfo/typo3-**english<http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english>
Muriel le Pair
2013-08-01 10:16:59 UTC
Permalink
Post by Henjo Hoeksma | Stylence
protected $defaultOrderings = array(
'sorting' => Tx_Extbase_Persistence_QueryInterface::ORDER_ASCENDING
);
I don't want to change the order but field that is used to order by.

I want it to use the sorting column:

SELECT * from table ORDER BY sorting.

currently it looks like the ordering by is something like this:

SELECT * from table ORDER BY uid.

--
kind regards,

Muriel le Pair
Henjo Hoeksma | Stylence
2013-08-01 10:42:56 UTC
Permalink
Hi Muriel,

I understand. But also ordering by uid is done either ascending or
descending.... I do not see the problem to be honest... but maybe I still
get you wrong ;-)

Kind regards,

Henjo

Problems are small because we learned how to deal with them.
Problems are big because we need to learn how to deal with them.
Post by Muriel le Pair
Post by Henjo Hoeksma | Stylence
protected $defaultOrderings = array(
'sorting' => Tx_Extbase_Persistence_**QueryInterface::ORDER_**
ASCENDING
);
I don't want to change the order but field that is used to order by.
SELECT * from table ORDER BY sorting.
SELECT * from table ORDER BY uid.
--
kind regards,
Muriel le Pair
______________________________**_________________
TYPO3-english mailing list
TYPO3-english at lists.typo3.org
http://lists.typo3.org/cgi-**bin/mailman/listinfo/typo3-**english<http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english>
Muriel le Pair
2013-08-01 10:54:44 UTC
Permalink
Post by Henjo Hoeksma | Stylence
Hi Muriel,
I understand. But also ordering by uid is done either ascending or
descending.... I do not see the problem to be honest... but maybe I still
get you wrong ;-)
The question is very simple.
I don't want to order by uid (ascending or descending) but on the
sorting column because this is much more flexible.

So how to you change the column that is used to sort on in extbase?

SELECT * from table ORDER BY sorting.

--
kind regards,

Muriel le Pair
Peter Linzenkirchner
2013-08-01 11:24:48 UTC
Permalink
Hello Muriel,

try this:

$query->setOrderings(array('sorting' => Tx_Extbase_Persistence_QueryInterface::ORDER_DESCENDING));


Peter
Post by Muriel le Pair
Post by Henjo Hoeksma | Stylence
Hi Muriel,
I understand. But also ordering by uid is done either ascending or
descending.... I do not see the problem to be honest... but maybe I still
get you wrong ;-)
The question is very simple.
I don't want to order by uid (ascending or descending) but on the sorting column because this is much more flexible.
So how to you change the column that is used to sort on in extbase?
SELECT * from table ORDER BY sorting.
--
kind regards,
Muriel le Pair
_______________________________________________
TYPO3-english mailing list
TYPO3-english at lists.typo3.org
http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english
--
Xing: http://www.xing.com/profile/Peter_Linzenkirchner
Web: http://www.typo3-lisardo.de
Facebook: http://tinyurl.com/lisardo-multimedia

Loading...