<![CDATA[ Adding a Sortby 'old/new' dropdown for articles - MODX Community Forums]]> https://forums.modx.com/thread/?thread=100558 <![CDATA[Adding a Sortby 'old/new' dropdown for articles]]> https://forums.modx.com/thread/100558/adding-a-sortby-039-old-new-039-dropdown-for-articles#dis-post-543393
I am trying to add a sortby dropdown option for my articles.

The option to select the order of display is in the advanced tab section but i'd like to provide that option in the front end.

Allowing users select what order they'd like to see. (Newest/Oldest).

I tried this -
<li><a href="[[~[[*id]]? &sortby=`ASC`]]">Newest</a></li>
<li><a href="[[~[[*id]]? &sortby=`DESC`]]">Oldest</a></li>

That didnt work.

Any suggestions/solutions will be welcomed]]>
niloba@topspotims.com Jul 19, 2016, 11:15 AM https://forums.modx.com/thread/100558/adding-a-sortby-039-old-new-039-dropdown-for-articles#dis-post-543393
<![CDATA[Re: Adding a Sortby 'old/new' dropdown for articles]]> https://forums.modx.com/thread/100558/adding-a-sortby-039-old-new-039-dropdown-for-articles#dis-post-543403
In the getResources tag:


Then a custom snippet:

/*GetSortBy snippet */
return $_GET['sortby'];

Also, your tags above are incorrect (you can tell by looking at the URL, which should have ? &sortby=`ASC` at the end). The parameter goes inside the link tag with no question mark:

<li><a href="[[~[[*id]] &sortby=`ASC`]]">Newest</a></li>

I always have to look at my own book to get this right. wink

You could also use placeholders and a little more code in the snippet so the user would see something like:

Sorted By Newest -- Sort by Oldest


Sorted by Oldest -- Sort by Newest]]>
BobRay Jul 19, 2016, 05:37 PM https://forums.modx.com/thread/100558/adding-a-sortby-039-old-new-039-dropdown-for-articles#dis-post-543403