solved How to list Forum categories by order Profile Arranged

Developer Networks
Developer Networks
@developer-networks
8 years ago
566 posts
I am trying to list the Forum categories in order they have been arranged by the profile. I have tried this but with out success
order_by="cat_order desc" 

I noticed cat_order is not passed in the $item... so would this require me to write a function that extracts the cat_order from the database or is this data already accessible to my template in the list?
updated by @developer-networks: 12/31/16 01:26:51AM
brian
@brian
8 years ago
10,148 posts
If you are in a jrCore_list call you can use:
order_by="forum_cat desc"
There's no way to list by the order as set in the Forum settings.


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

updated by @brian: 09/27/16 10:47:33AM
Developer Networks
Developer Networks
@developer-networks
8 years ago
566 posts
Yeah, I was noticing those variables are not accessible from the jrCore_list also. Thanks for verifying that. Also, Just a suggestion...it may be better they were included in the jrCore_list function for future use for other Jamroom users.

I am having to building a module now just to work with them in a template but the variable is already saved in the jrForum Data store.

It would had made life easier to just be able to use
{jrCore_List module="jrForum" order_by="cat_order_id desc" ....}

or something...

Anyways, thanks for your help and I appreciate your time! :)


updated by @developer-networks: 09/27/16 06:18:37PM
michael
@michael
8 years ago
7,715 posts
'forum_cat' and 'forum_cat_url' are stored in the jrForum datastore, the order is not. Its a performance thing.

If we stored the forum_cat_order in the jrForum datastore, when the order was changed every datatore item would need to be updated.

Performance wise its better as is. You can write a smarty function to get the categories and their order first if needed:

Docs "Defining your own smarty function"
https://www.jamroom.net/the-jamroom-network/documentation/jamroom-developers-guide/1569/defining-your-own-smarty-function

Then run a foreach loop over the returned categories to get the contents for each of them.

The forum categories are stored in the 'jr_jrforum_category' table so a query like this will get the order your after:
SELECT * FROM `jr_jrforum_category` WHERE cat_profile_id = 1 ORDER BY cat_order asc
Developer Networks
Developer Networks
@developer-networks
8 years ago
566 posts
Thanks Michael. That's exactly how I've solved it last night after writing this. :) I learned a lot about controlling another module on this one.

I dont think that It would be a load bearing problem to the server at all. My module I created that takes care of this functionality does not even cause a page hick up when loading.

Any rate thanks for your help and suggestions.
They are all very appreciated!


updated by @developer-networks: 09/28/16 03:18:05AM

Tags