listing one quota above another

blindmime
@blindmime
9 years ago
772 posts
Is there a best way to list items from one quota over another in a jrCore_list? Ideally specified in the function call itself.

My purpose is to list items from premium quotas before those from non-premium ones.
updated by @blindmime: 02/03/16 11:36:11PM
brian
@brian
9 years ago
10,148 posts
blindmime:
Is there a best way to list items from one quota over another in a jrCore_list? Ideally specified in the function call itself.

My purpose is to list items from premium quotas before those from non-premium ones.

Yep - when you do your search, make sure and place the quota_id's in the order you want - i.e.

search="quota_id in 1,2,3,4,5,6,7,8,9"

They will appear in the order you list them.

Hope this helps!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
blindmime
@blindmime
9 years ago
772 posts
What is "quota_id in"?
michael
@michael
9 years ago
7,715 posts
IN is an option for searching for stuff.

"Search conditions in jrCore_list"
http://www.jamroom.net/the-jamroom-network/documentation/development/89/jrcore-list#search-conditions

It means "any of these"

so search for any of these quota ids could be stated as "quota_id in 2,3,4,5" and that would mean only get the item if it is in quota 2 or 3 or 4 or 5
blindmime
@blindmime
9 years ago
772 posts
Shouldn't the search be: search1="profile_quota_id in 6,1"?

The "in" clause doesn't appear to order the list in the order of the values, i.e. list profiles found in quota_id 6 before profiles found in quota_id 1. It appears to work as an OR.

Is there a way I can do that?
blindmime
@blindmime
9 years ago
772 posts
Any thoughts?
paul
@paul
9 years ago
4,326 posts
Do the above search1="profile_quota_id in 6,1" then in the template, run the {foreach} loop twice -

{foreach from=$_items item="item"}
    {if $item.profile_quota_id == 6}
        // Item row code here
    {/if}
{/foreach}
{foreach from=$_items item="item"}
    {if $item.profile_quota_id == 1}
        // Item row code here
    {/if}
{/foreach}



--
Paul Asher - JR Developer and System Import Specialist

updated by @paul: 10/30/15 05:02:19AM
blindmime
@blindmime
9 years ago
772 posts
Yeah, I was hoping for a way to do it in the jrCore_list call. Brian says the "in" clause should do it, but that's not working for me. Am I doing it wrong?
paul
@paul
9 years ago
4,326 posts
I don't think what you want to do is going to work out of the box. You are wanting to order the result of a jrCore_list call by profile_quota_id but specify the order within the call. It will either need a custom module that listens for the 'db_search_items' event and does the ordering there, or at a template level, as described above.


--
Paul Asher - JR Developer and System Import Specialist
brian
@brian
9 years ago
10,148 posts
blindmime:
Yeah, I was hoping for a way to do it in the jrCore_list call. Brian says the "in" clause should do it, but that's not working for me. Am I doing it wrong?

It only works if the IN clause in the search is searching on a KEY that is from the module being searched. In this case the IN clause is looking for quota_id, but you're probably listing from a module that is NOT the jrProfile module.

You will need to do it like Paul shows.


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
blindmime
@blindmime
9 years ago
772 posts
This is my call:

{jrCore_list module="jrProfile" search1="profile_active = 1" search2="profile_category like %`$_post.procat`%" search3="profile_quota_id in 6,1" pagebreak=15 page=$_post.p pager=true}

It doesn't order quota 6 profiles before quota 1 profiles. I don't get any results if I search for "quota_id," by the way.
paul
@paul
9 years ago
4,326 posts
Add in an 'order_by' -

{jrCore_list module="jrProfile" search1="profile_active = 1" search2="profile_category like %`$_post.procat`%" search3="profile_quota_id in 6,1" order_by="profile_quota_id NUMERICAL_DESC" pagebreak=15 page=$_post.p pager=true}


--
Paul Asher - JR Developer and System Import Specialist
blindmime
@blindmime
9 years ago
772 posts
That's assuming the featured profiles I want listed first are in a quota with a higher numerical value than the profiles I want listed afterwards, correct?

And search3 with its IN clause isn't doing the ordering here. I can't use something like search3="profile_quota_id in 4,6,1" to determine the order?
paul
@paul
9 years ago
4,326 posts
Quote: I can't use something like search3="profile_quota_id in 4,6,1" to determine the order?

No - Jamroom just isn't built to work that way. Your only options are what have been outlined above.


--
Paul Asher - JR Developer and System Import Specialist
brian
@brian
9 years ago
10,148 posts
blindmime:
I can't use something like search3="profile_quota_id in 4,6,1" to determine the order?

Actually I think that would work, but that has to be the only search condition.

Also - as an FYI you can drop the searches for profile_active - the datastore already handles active/private profiles for you so you don't have to worry about it.

Hope this helps!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net

Tags