32 Posts
perrineco
3 years ago
5
Topic

Hello

I try to order a list using a field before render.

Therefore I put a beforerender field in the search form of the list and in this field, I am modifying  $config['pks'].

I played with the priority

However, it looks like this field is used after the display of the list. 

What should I do? All my fields are up to date.

Thanks !

Perrine

Get a VIP membership
4229 Posts
Kadministrator
3 years ago
3
Level 1

Unfortunatelly there is no such thing as beforeRender on list, you can only modify individual items but not the list.

32 Posts
perrineco
3 years ago
2
Level 2

OK; so why is it written "

Before Render

As name of the event says, it is executed before content, list or form is rendered." on this post : using code pack ?

Moreover, you said 'beforerender should work, but I presume you will need to put it in the search form. If your changes can be done just with sql you cna use search query field (it has order section)' in this topic https://www.seblod.com/community/forums/lists-search-types/list-ordering-with-custom-code

Thanks for your help,

Perrine 

4229 Posts
Kadministrator
3 years ago
1
Level 3

You can use beforeRender to modify each item in list, but not the whole list. From what I knwo the only viable way to do this is to make your own template.

32 Posts
perrineco
3 years ago
0
Level 4

Hello

thanks for you answer

I tried that but when I insert a function in the index.php I get a fatal error...I would need to use a recursive function but can't  do it. Any idea, suggestion?

Thanks again!

perrine

200 Posts
iliil
3 years ago
0
Level 1

Hi

You can manage the ordering of items in your search type. If the tools are not enough to build the right query, you may consider purchasing some advanced plugin e.g. Search Query.

If you still need to perform some reordering after you got items from the database, you can do it in a custom list template, as Klas suggested above. You'll find the items in the array $items and it is up to you what you will do with that.

Michal

Get a VIP membership