HTML Logo by World Wide Web Consortium ( Click to learn more about our commitment to accessibility and standards.

Moving forward with Composr

ocPortal has been relaunched as Composr CMS, which is now in beta. ocPortal 9 will be superseded by Composr 10.

Head over to for our new site, and to our migration roadmap. Existing ocPortal member accounts have been mirrored.

Duplicating the Member Code

Login / Search

 [ Join | More ]
 Add topic 
#98234 (In Topic #19403)


I have found some of the code I need to duplicate the member list page, but I haven't been able to find the ability to add the sorting and paging scripts.

I am pulling a roster in through an API and want it to display like the members page.

Where can I find the source code for the sorting script and adding the sort buttons/logic and paging.


Russ Teicheira or - OCPortal Install
 - Profile Site that needs updating - Tech Blog that I need to get back to
Back to the top


So long as you know programming, it shouldn't be too hard.

These are the three main functions for the UI:
  • results_field_title (defines field header templating)
  • results_entry (defines individual result row templating)
  • results_table (defines the surrounding interface)

You compose some results_field_title together using PHP arrays, to form the combined header.

You compose some results_entry together using Tempcode attach, to put the rows together.

Then you pass it, and some other stuff (all defined in the documented API / observable by many examples), to results_table.

That's all UI work. The actual sorting and pagination is trivial, it's simply done within your database query (usually query_select). results_table will have bound UI widgets to the GET parameters needed to determine sorting and the start position in the result set, and the maximum number of results to return.

The only real caveat is you need to be careful to not read in the sort order from the GET parameter for it and put it straight into a query, because that's a vulnerability.
That is why you see code like:


      if (((strtoupper($sort_order)!='ASC') && (strtoupper($sort_order)!='DESC')) || (!array_key_exists($sortable,$sortables)))

Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top


Thanks.  Hopefully that will help.

Russ Teicheira or - OCPortal Install
 - Profile Site that needs updating - Tech Blog that I need to get back to
Back to the top
There are too many online users to list.
Control functions:

Quick reply   Contract

Your name:
Your message: