Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Archive

Ajax

Started by Muut Archive 11 years ago · 2 replies · 316 views
11 years ago

Lost my last post so have to settle for a hurried one. Nice work on Grav - have looked at a LOT of these in the last while and coming from Kirby, I like what I see so far (esp the docs). I'm building a site to showcase my students (3rd level) projects across three streams (soft/games/web).
My initial plan is to have a folder structure like 2014/soft, 2014/games, 2013/soft etc. so that the user is forced to choose a year first and then further specify the stream thereby inherently limiting the number of returned projects (no more than 60 in total in a year) - perhaps then filtered by Masonry or similar.
Is this a plan? I'm then thinking of using Taxonomy to handle tagging and searching thereof?
Lastly, is Ajax an option so I could inject the returned results between header/footer?

Sorry for brevity,
Thanks,
John K

11 years ago

Yah sorry about the lost post. It's beyond frustrating. I have told the Muut guys about it, but they have yet to do anything. My common practice now is to copy my post to clipboard before submitting, just in case!

Anyway, to your post. Your plan seems quite viable, breaking up into sub folders is smart and will be the optimal way of organizing and managing. As well as help performance. Taxonomy will allow you to filter like your thinking and we had our downloads working in a similar manner before we rewrote it and moved away from pages to a 100% pure github/json solution powered by a custom plugin.

Ajax is totally an option, it's natively supported and we use it extensively. There is obviously two parts when it comes to ajax: 1) the server side for processing/sending data, and 2) the client side to initiate/process that data.

On the server side, you can either write that logic via pages and twig templates, just outputting in json format by using the Twig json_encode filter. Or you can write a custom plugin that does the processing and then just set the finalized json encoded data as a Twig variable, then just simply output it with Twig. You would create a twig template called "results.json.twigor something. Then when you make the request:/mypage.json, Grav automatically will render as JSON and look for a.json` template to render it. Then it's just regular Javascript to request and process that json.

This is all very doable :)

11 years ago

thanks Andy, good to know I'm on the right track. Have just visited Themeforest so can start plugging in some Twig and see what breaks ;)

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1318 9 years ago
Archive · by Muut Archive, 9 years ago
2 915 9 years ago
Archive · by Muut Archive, 9 years ago
2 4044 9 years ago
Archive · by Muut Archive, 9 years ago
1 2920 9 years ago
Archive · by Muut Archive, 9 years ago
3 1103 9 years ago