Custom json web services in Concrete5 with custom db tables
Permalink
Hi all.
I'm pretty new to C5 and one thing I need to build for this project are some web services that are called via ajax within a page. A breakdown would be something like this:-
Build a custom block that loads a HTML5 mini game
The mini game pulls data from a custom c5 db table and returns it as json
The mini game sends score data via ajax to a custom c5 db table
My question is then, what is the best way to do this within C5? I have found info on the Loader::db(); class but how best to handle views that pull and save the data?
Thanks
I'm pretty new to C5 and one thing I need to build for this project are some web services that are called via ajax within a page. A breakdown would be something like this:-
Build a custom block that loads a HTML5 mini game
The mini game pulls data from a custom c5 db table and returns it as json
The mini game sends score data via ajax to a custom c5 db table
My question is then, what is the best way to do this within C5? I have found info on the Loader::db(); class but how best to handle views that pull and save the data?
Thanks
If developing this for 5.6, you can see such a setup in action on my concrete bricks and concrete paving addons for 5.6.
Does this apply to 5.7 too?
Ideally, I would like to have the functionality contained in my block if possible.
Thanks
Ideally, I would like to have the functionality contained in my block if possible.
Thanks
Ajax is different in 5.7, you have to register a route to a controller. There is some stuff about it in the docs and howtos
Thanks John. I worked out how to do it. Alas, the forum won't let me post a reply to this thread with a full example. (I get 403 forbidden when trying to post it. Perhaps the post length is to big?)
The forum won't let you attach php files (and some other executables) directly to a post.
Alternatives
A) Use
[ code ]
[ / code ]
B) make the file filename.php.txt and attach it
C) Attach a zip
D) Write it up as a howto. However, the code highlighting for howtos is not as good as forum attachments and has issues with embedding <tags>
Alternatives
A) Use
[ code ]
/*
remove the spaces to make code sections work
Its great for snippets and even up to 100 lines, but gets messy later.
You can have multiple code sectione in a post
*/
[ / code ]
B) make the file filename.php.txt and attach it
C) Attach a zip
D) Write it up as a howto. However, the code highlighting for howtos is not as good as forum attachments and has issues with embedding <tags>