I’m trying to create a site with two templates combined.
At first I tried with iFrame, but it doesn’t seem to be a good idea.
I have never used AJAX before, and this time I first learned AJAX.
So I read everything in the Kirby community and the Cookbook, but I don’t know how to use it in my situation.
Can you help me?
I want to load /site/templates/bookshops.php and /site/templates/programs.php in the /site/templates/home.php file.
Thank you very much for writing the code.
Please let me know if I need to use a controller or plugin.
The solution here would be to use different blueprints (for the Panel), but two snippets instead of templates to render those two parts in the home template.
Thank you for answer.
But if I use snippets, does the whole screen reload again?
I want the right side to change when I click the right side, or the left side to change when I click the left side.
I see. Well, basically, you need two sections. These sections would have a snippet each for each overview. Then when you click on a link, you load the target via Ajax into that section. For this purpose, use content representations of the templates you want to load.
Since you already load the snippet, there is no reason to try and load it again at document load via Ajax. So your first load can be without Ajax, or alternatively, you do not include the snippet in the home template and load it via Ajax on page load. So not A+B, but A or B.
For the Ajax call, you would json_encode your snippet in the bookshops.json.php template, then call the URL https://your.domain/bookshop.json (without the PHP extension) in your Ajax request.
And ajax works but no content.
If ajax succeeds, the content should be between <div class = "leftscreen" id = "leftscreen"> </div>, and appear on the left side of the website.