MIGX: How to sort items starting with "pinned" items first

I’m not sure how to code something like this.

I have a list in the backend that is sorted from oldest (top of list) to newest (bottom). But the content on the page displays from left (newest) to right (oldest).

I added a TV field in the MIGX item called “pinned” and it’s a checkbox with a value of “yes==1”.

How can I output my “pinned” items first, and then the rest of my content?

Thanks

Hi,

But the content on the page displays from left (newest) to right (oldest).

Is this about backend too or frontend?

Not sure I’ve got your idea properly, but for MIGX DB this may be helpful: How to set sort order in a component created with MIGXdb? | MODX Community Forums

left to right is on the frontend.

Unfortunately the link didn’t work.

hopefully the only you need is &sort parameter for getImagesList snippet(if we talk about single page content)
https://docs.modx.com/current/en/extras/migx/migx.frontend-usage
&sort=[{"sortby":"pinned","sortdir":"ASC"}]
Otherwise maybe this will help if speech is about resources list:
https://docs.modx.com/current/en/extras/migx/migx.tutorials/sortable-resourcelist

unfortunately no, that doesn’t work and the order on the frontend just gets mixed up.

You might have to call the snippet twice i.e.

[[- Get the pinned items first ]]
[[getImageList?
    &tvname=`myMIGXtv`
    &tpl=`thumbTpl`
    &limit=`1`
    &docid=`[[+id]]`
    &where=`{"pinned:=":"1"}`
  ]]
[[- Get the rest ]]
[[getImageList?
    &tvname=`myMIGXtv`
    &tpl=`thumbTpl`
    &limit=`1`
    &docid=`[[+id]]`
    &where=`{"pinned:!=":"1"}`
  ]]
1 Like

Hmm i was thinking about that too. But I’m concerned with how the tpl chunk is set up. I’ll give it a shot and let you know.

I think, this should work, with this two calls, no?