Asset to return 1 month of events in JSON format


(Nic Hubbard) #1

For years I have been looking for a better solution to this issue. I would like to output 1 month of Calendar events in JSON format, also passing in a GET var for a different month and show those events. 

 

Calendar Page is ideal to use, but has the following issues that prevent it from being a workable solution:

 

- Prints extremely annoying default Calendar javascript that cannot be removed without editing the asset php.

- Does not have Position formats so that I can edit the last JSON item and remove the comma to make it valid JSON. This can easily be done with an Asset Listing.

 

Other things I have thought about:

 

- Using an Asset Listing and Listing all Calendar Assets the filtering out the month in my application (does not sound fun)

- Using another Calendar type listing, but none of those provide what I need as well as Dynamic Params

- Calendar Event Search page, but for some reason that blows my mind, you cannot provide a event date range.

- JS API is NOT an option.

 

The last option I had thought about is a DB Source asset and does  a DB query on the Matrix database. Then I could cleanly return the events how I want and pass in Dynamic Params.

 

Does anyone else have ideas? Why does it have to be so hard? It seems like such a simple thing...

 

Help me out and give me my sanity back on this issue!


(Nic Hubbard) #2

I guess I had to solve my own issue:

 

  • Edited page_calendar.inc to comment out the lines that print the JS
  • Nested the Calendar Page into a Standard Page so that I could add an empty {} at the end of the listing so that I would have valid JSON.

 

Not sure what else I could have done...


(Bart Banda) #3

Could you not have used a calendar search page and pass dynamic parameters as the search for from and to date?

 

If you want the search parameters to be clean, you could maybe output the year and month into a default metadata field, for example "January2015" and use that as a default stored search value?

 

You should however be able to pass the from and to date as per the normal search parameters that you get when you do a manual search. 


(Nic Hubbard) #4

Could you not have used a calendar search page and pass dynamic parameters as the search for from and to date?

 

If you want the search parameters to be clean, you could maybe output the year and month into a default metadata field, for example "January2015" and use that as a default stored search value?

 

You should however be able to pass the from and to date as per the normal search parameters that you get when you do a manual search. 

 

How reliable is a search vs. a listing? Would a search find ALL assets that a listing would?


(Bart Banda) #5

 

How reliable is a search vs. a listing? Would a search find ALL assets that a listing would?

 

Off course, why wouldn't it? As long as you've got your search fields set up correctly it should work fine. You can always do a comparison by allowing "Allow empty searches" and do an empty search and compare the result count with an asset listing result. 


(Nic Hubbard) #6

 

Off course, why wouldn't it? As long as you've got your search fields set up correctly it should work fine. You can always do a comparison by allowing "Allow empty searches" and do an empty search and compare the result count with an asset listing result. 

 

I just have never found Matrix search very reliable. That is why I questioned it.