Search by _profile_ids, order by profile_id

SteveX
SteveX
@ultrajam
2 years ago
2,584 posts
Hi, I'm using jrCore_list in a template to search by multiple _profile_ids and order by _profile_id but getting an error in the activity log "you must include the _profile_id field in your search criteria to order_by it".

I'm sure I can sort it out in the template, but should it be working, or am I just missing something obvious?

{jrCore_list module="ujStatement" search="_profile_id in `$_user['user_linked_profile_ids']`" order_by="_profile_id numerical_asc" template="list.tpl" tpl_dir="ujManager"}

From the activity log:

Array
(
[0] => error: you must include the _profile_id field in your search criteria to order_by it
[1] => ujStatement
[2] => Array
(
[jrcore_list_function_call_is_active] => 1
[search] => Array
(
[0] => _profile_id in 3, 5, 6, 7, 8, 9, 10
[1] => _profile_id in (SELECT `_item_id` FROM jr_jrprofile_item_key WHERE `key` = 'profile_quota_id' AND `value` IN(1))
)

[order_by] => Array
(
[_profile_id] => numerical_asc
)

[template] => select_statements_to_zip.tpl
[tpl_dir] => ujManager
[module] => ujStatement
)

[3] => Array
(
[jrcore_list_function_call_is_active] => 1
[search] => Array
(
[0] => _profile_id in 3, 5, 6, 7, 8, 9, 10
)

[order_by] => Array
(
[_profile_id] => numerical_asc
)

[template] => select_statements_to_zip.tpl
[tpl_dir] => ujManager
[module] => ujStatement
)

)


--
¯\_(ツ)_/¯ Education, learning resources, TEL, AR/VR/MR, CC licensed content, panoramas, interactive narrative, sectional modules (like jrDocs), lunch at Uni of Bristol. Get in touch if you share my current interests or can suggest better :)

updated by @ultrajam: 10/02/22 11:48:08PM
michael
@michael
2 years ago
7,746 posts
does order by _created work? because I'd expect that would give the same order as _profile_id
SteveX
SteveX
@ultrajam
2 years ago
2,584 posts
_created does work, but lists in the order that the items are created rather than by profile.

Profile 1 creates item 10, profile 2 creates item 11, profile 1 creates item 12.

The order I want is 10, 12, 11


--
¯\_(ツ)_/¯ Education, learning resources, TEL, AR/VR/MR, CC licensed content, panoramas, interactive narrative, sectional modules (like jrDocs), lunch at Uni of Bristol. Get in touch if you share my current interests or can suggest better :)
michael
@michael
2 years ago
7,746 posts
Without a system connected to a debugger to test out my next step would probably be either:

Create a new smarty function instead of the jrCore_list call something like {ujStatement_get_stuff user_ids=$_user['user_linked_profile_ids']}

then use the jrCore_db_search_items to get all the wanted items and run them through a foreach loop to get the ordering in the desired order.

Then pass that info to list.tpl in ujManager.

--edit--
forgot the OR. Or assign the results of the jrCore_list to a variable then loop over that to get them in the right order before passing them off to the list.tpl file. The previous way I prefer because I like loops and this kind of stuff better in php than in smarty.
updated by @michael: 06/28/22 02:24:36AM
SteveX
SteveX
@ultrajam
2 years ago
2,584 posts
Thanks Michael, a new smarty function it is :)


--
¯\_(ツ)_/¯ Education, learning resources, TEL, AR/VR/MR, CC licensed content, panoramas, interactive narrative, sectional modules (like jrDocs), lunch at Uni of Bristol. Get in touch if you share my current interests or can suggest better :)

Tags