Problems, need help? Have a tip or advice? Post it here.
5 posts Page 1 of 1
Or, can I get cms:pages to deliver pages in the order provided by the id parameter?

So, I am running a db query that I don't see how to successfully use Couch's amazing regular features to accomplish. To be to the point, I don't want to overload the built in publish_date for event start times. I have my reasons.

Using separate start_date start_time and a custom SQL query via cms:query I can get exactly the right page id's in the right sort order that I want for events, (everything today or later, sorted in nearest time (asc) order. My challenge is when I later call cms:pages with the ids in sort order it returns them in its own order. What's weird is that the orderby used in the cms:pages call with an id set to a list, does not seem to actually use the orderby. Or, if it does, 11:00 is now < 08:00. This may be a real bug, I have not simplified this to a test case to see if there is a bug when using id and orderby together.

I know my SQL is correct, because when I run it straight against the db I see the results I want and expect. I also see through cms:dump that I capture those values in the proper order, with the proper separator, ",", to be used with the id parameter of cms:pages. However the order I am seeing my data displayed in the HTML page does not match the database, the id list, or the orderby order.

My results straight from the db:
Code: Select all
pid   tname        fdname       ddvalue      ftname       dtvalue
114   events.php   start_date   2015-05-18   start_time   08:00
113   events.php   start_date   2015-05-18   start_time   11:00
130   events.php   start_date   2015-05-22   start_time   12:00


The id list my page ids are captured into:
Code: Select all
definitely_future: 114, 113, 130

My cms:pages call:
Code: Select all
 <cms:pages masterpage='events.php'
   id=definitely_future
   orderby='start_date, start_time'
   order='asc' paginate='1' limit='6'>...</cms:pages>


The order I am seeing my pages displayed in my HTML page is:
113, 114, 130

I am happy to work on helping debug this problem, but right now I need a solution to just get this working correctly. I was intending on being finished with this site tomorrow. Clearly, that may not happen.

Thank you kk and cheesypoof for such an amazing website creation tool. I love CouchCMS, and still think about
how I'd implement a similar tool with flat files for the really simple sites. Not every site needs a RDBMS back end, great opensource software just made it too easy to do, and now almost everyone does.

For anyone curious as to why I did not just use comparison operators with the custom_field parameter of cms:pages, I did try. I found that although comparison operators work in cms:if statements with date or time strings, they are not useable in the former context. Believe me, I wish they had been. My life would have been a lot easier.
My bad again. The order parameter of pages can take a value for each order by field, and I was not setting the second fiedl explicitly to 'asc'. :oops:

atenhotep wrote: Or, can I get cms:pages to deliver pages in the order provided by the id parameter?

So, I am running a db query that I don't see how to successfully use Couch's amazing regular features to accomplish. To be to the point, I don't want to overload the built in publish_date for event start times. I have my reasons.

Using separate start_date start_time and a custom SQL query via cms:query I can get exactly the right page id's in the right sort order that I want for events, (everything today or later, sorted in nearest time (asc) order. My challenge is when I later call cms:pages with the ids in sort order it returns them in its own order. What's weird is that the orderby used in the cms:pages call with an id set to a list, does not seem to actually use the orderby. Or, if it does, 11:00 is now < 08:00. This may be a real bug, I have not simplified this to a test case to see if there is a bug when using id and orderby together.

I know my SQL is correct, because when I run it straight against the db I see the results I want and expect. I also see through cms:dump that I capture those values in the proper order, with the proper separator, ",", to be used with the id parameter of cms:pages. However the order I am seeing my data displayed in the HTML page does not match the database, the id list, or the orderby order.

My results straight from the db:
Code: Select all
pid   tname        fdname       ddvalue      ftname       dtvalue
114   events.php   start_date   2015-05-18   start_time   08:00
113   events.php   start_date   2015-05-18   start_time   11:00
130   events.php   start_date   2015-05-22   start_time   12:00


The id list my page ids are captured into:
Code: Select all
definitely_future: 114, 113, 130

My cms:pages call:
Code: Select all
 <cms:pages masterpage='events.php'
   id=definitely_future
   orderby='start_date, start_time'
   order='asc' paginate='1' limit='6'>...</cms:pages>


The order I am seeing my pages displayed in my HTML page is:
113, 114, 130

I am happy to work on helping debug this problem, but right now I need a solution to just get this working correctly. I was intending on being finished with this site tomorrow. Clearly, that may not happen.

Thank you kk and cheesypoof for such an amazing website creation tool. I love CouchCMS, and still think about
how I'd implement a similar tool with flat files for the really simple sites. Not every site needs a RDBMS back end, great opensource software just made it too easy to do, and now almost everyone does.

For anyone curious as to why I did not just use comparison operators with the custom_field parameter of cms:pages, I did try. I found that although comparison operators work in cms:if statements with date or time strings, they are not useable in the former context. Believe me, I wish they had been. My life would have been a lot easier.
Hi atenhotep :)

I'm glad the problem is resolved.
I'd, however, be interested in the observation you made -
For anyone curious as to why I did not just use comparison operators with the custom_field parameter of cms:pages, I did try. I found that although comparison operators work in cms:if statements with date or time strings, they are not useable in the former context. Believe me, I wish they had been. My life would have been a lot easier.

Could you please expand on that? I'd appreciate if you could send me some test data and the code you were trying to use. I'd like to test it out myself as to why the comparison operators were not working within 'custom_field' parameter.

Thanks.
KK,

Sorry I didn'ty reply to this sooner. I don't recall getting an email about your reply, and only found
this by accident now when searching for something else.

It's been months, but I will try and find where I was to generate data to test this against, and tell
you if it is still a problem. I am using 1.4.5 now, too, if that matters. It may be up to a week
before I get to this.
Not a problem, @atenhotep :)
I'm glad you are willing to pursue this after such a long interval.
5 posts Page 1 of 1