App Connect Data Formatter Support Product Page

Answered

Can I use 'sort' in the Collections options to reverse the order of items that I've grouped using

Asked 23 Aug 2018 13:38:39
1
has this question
23 Aug 2018 13:38:39 Bruce Wilkie posted:
Hi there

I've used group by already to group my photographs into albums on the page with a thumbnail for each album.

The pictures are selected using a query that lists them in Descending order using the primary key 'gallerypicid', but when I group them together by 'galleryid' using App Connect Data Formatter, the albums are now appearing in Ascending order.

I don't know what's causing this but I've looked at other options in the 'Collections' contextual menu in Data Formatter and there is one labeled 'Sort'. I've appied this to my repeat region alongside the 'group by' and it appears as follows in the repeat code:

dmx-repeat:repeatgalleries="serverconnectshowgalleries.data.showgeneralgalleries.sort(galleryid).groupBy(`galleryid`)"

It hasn't made any difference, but for all I know it is sorting the results in Ascending order still. If that's the case, can I reverse the sort order to sort the reslts on the page in Descending order using this?

Or if not, how do I list the results in Descending order on the page?

Note, if I don't use 'group by' then all the pictures appear on the page in Decending order of galleryid. It's only when I apply the 'group by' in Data Formatter that the order switches to Ascending order.

thanks in advance
Bruce

Replies

Replied 24 Aug 2018 12:12:53
24 Aug 2018 12:12:53 Teodor Kuduschiev replied:
Hello Bruce,
It is not currently possible to sort by a custom property when using group by with the existing formatter options.
Replied 24 Aug 2018 12:21:32
24 Aug 2018 12:21:32 Bruce Wilkie replied:
Hi Teodor

Thanks for the reply.
Is this a bug in the software, or just something that wasn't implemented when it was made?
And is it something you're looking at fixing or implementing in future updates?

Also, if this isn't what the 'sort' facility is for, could you let me know what it is for, just in case it's useful to me in future projects?

thanks
Bruce
Replied 29 Aug 2018 14:15:29
29 Aug 2018 14:15:29 Bruce Wilkie replied:
Hi Teodor

Just checking if you've had time to look at a fix for this yet?

Bruce
Replied 29 Aug 2018 14:58:46
29 Aug 2018 14:58:46 Teodor Kuduschiev replied:
Hello Bruce,
QuoteIs this a bug in the software, or just something that wasn't implemented when it was made?


Sort is not implemented for group by. And i don't have any timeframe when is such an option going to be added.
Replied 29 Aug 2018 15:50:08
29 Aug 2018 15:50:08 Bruce Wilkie replied:
Hi Teodor

Sadly, this has completely shafted me

I promised my client that we could sort his photo albums with the most recent at the top of the page, just like on his previous website, and on pretty much every picture album website on the internet. And now I have to tell him, after they've paid me, that it's no longer possible.
That photo albums can either show how many pictures are contained within, or they can be sorted with most recent at the top. But no both...

I do hope you're able to look into this soon. Or make it so that we can 'group by' and 'sort by' using Server App

I'm currently looking at the php scripts that Server App creates when inserting a database query. If I can find out how these work, would I be able to try altering the scripts to add in group by and sort by do you think?

Bruce
Replied 29 Aug 2018 19:17:00
29 Aug 2018 19:17:00 Teodor Kuduschiev replied:
But why do you insist on using group by on the front-end?

Is all you want to do - show albums on a page, sorted by id>descending and show how many photos your albums contain? How are the photos stored and how are the albums stored in the database?

No, we don't support custom coding nor we support issues caused by changing any of the script file.
Replied 30 Aug 2018 11:19:41
30 Aug 2018 11:19:41 Bruce Wilkie replied:
Hi Teodor, yes that's exactly what I'm wanting to do.

I did the group by the way I did, just following the video that you linked me to in a previous thread (www.dmxzone.com/support/32763/topic/64474/)

If there's another way to do what I'm wanting then that's great. Could you let me know how?

thanks
Bruce
Replied 30 Aug 2018 11:37:24
30 Aug 2018 11:37:24 Teodor Kuduschiev replied:
Well, i'd suggest nesting the photo database table under the albums on the serverside: www.dmxzone.com/go/32997/nesting-database-queries/

Then you can directly sort, filter etc in the query builder - no need of group by.
Replied 31 Aug 2018 09:35:30
31 Aug 2018 09:35:30 Bruce Wilkie replied:
Thanks Teodor

Had a look through the video and looks straight forward enough. But doesn't say how to count the pictures and show that on the page. Could you let me know how to do that?

thanks
Bruce
Replied 31 Aug 2018 10:05:37
31 Aug 2018 10:05:37 Teodor Kuduschiev replied:
Well, use the collection filters on the page - there is a filter called "count"
Select the query, then select collections > count: prntscr.com/kp0kwd
Replied 03 Sep 2018 13:30:29
03 Sep 2018 13:30:29 Bruce Wilkie replied:
Hi Teodor

Not sure where to look for the collection filters on the page. Tried right-clicking on the nested query in Server App to bring up a contextual menu, but it's different to othe one you screenshotted for me, so I'm guessing it must be elsewhere. Could you let me know what I need to click on and where to bring up the options you showed me?



thanks for your patience
Bruce
Replied 03 Sep 2018 13:33:21
03 Sep 2018 13:33:21 Teodor Kuduschiev replied:
Bruce you do this on the page where you bind data, not in the server connect action ... just see my screenshot in the last reply.
Replied 03 Sep 2018 13:55:16
03 Sep 2018 13:55:16 Bruce Wilkie replied:
Hi Teodor

Binding data isn't working now. Looks like repeat isn't either. Therer's nothing showing on the screen where the picture albums should be when I view the web page.

Is there any way you can look at the files to see where it's going wrong?

Bruce
Replied 03 Sep 2018 14:00:02
03 Sep 2018 14:00:02 Teodor Kuduschiev replied:
What do you mean by "Binding data isn't working now"?
Just create a repeat region from the repeatGalleryTitles and inside it bind the nested query with the applied count filter to it.
Replied 03 Sep 2018 14:22:29
03 Sep 2018 14:22:29 Bruce Wilkie replied:
Hi Teodor

My bad on that last one. Had an error in the sql so was returning no values.

Fixed that now and I think I'm nearly there. I've brought up the contextual menu that looks like the same one you have in your screenshot. Only issue I have is that there's no 'Collections' in the menu below 'Conditional'

I've screenshoted the window along with the previous one in case that can give a clue as to what I'm doing wrong



Bruce
Replied 03 Sep 2018 14:24:57
03 Sep 2018 14:24:57 Teodor Kuduschiev replied:
You selected wrong binding. The count filter is applied to the query, not to a binding from a query: prntscr.com/kq393s
Replied 03 Sep 2018 14:25:10
03 Sep 2018 14:25:10 Bruce Wilkie replied:
Tried with selecting the showGalleryPics item in the list as well, but no collections there either when I brought the menu up



I know I'm close. Hope you can help

Bruce
Replied 03 Sep 2018 14:25:40
03 Sep 2018 14:25:40 Bruce Wilkie replied:
OK, trying that now

thanks
Bruce
Replied 03 Sep 2018 14:25:40
03 Sep 2018 14:25:40 Bruce Wilkie replied:
OK, trying that now

thanks
Bruce
Replied 03 Sep 2018 14:32:51
03 Sep 2018 14:32:51 Bruce Wilkie replied:
Hi Teodor

Half worked. I'm getting the picture count ok, but it's being repeated on the page rather than just one number.

Screenshot showing what I mean:



Screenshot showing the code that's producing this result:



Bruce
Replied 03 Sep 2018 14:53:03
03 Sep 2018 14:53:03 Bruce Wilkie replied:
OK, got it now.

Didn't realise I didn't need to apply the second repeat mentioned in the video for this.

Just going to check to make sure I can still bring up the thumbnail image as well and if so that's it all working perfectly

Bruce
Replied 03 Sep 2018 15:00:01
03 Sep 2018 15:00:01 Bruce Wilkie replied:
All working now.

Thanks for your help Teodor, much appreciated

Bruce

Reply to this topic