I think you can render the page via the tpl::load function (more info). That way you wouldn’t need to do the hassle with setting up a “hack”-content representation, but could render the page into a variable inside the controller.
Only grabbing the <main> contents, would be possible with a regex on the returned string from the tpl::load function I think.
so i ended up testing both options only today and:
the tpl:: approach spits back an error saying that Call to a member function title() on null from the code i have in my header.php snippet
the $kirby->render approach keeps saying it is rendering a null object, no matter which page or url i tried to load
the only reason i went back to this is that i was using file_get_contents() to call another page and render it through mPDF. But on the production server with SSL, this gives me an error (could be because is php 5.6 — i’m not the sysadmin in this case and can’t upgrade the server software stack).
it would be great if i did not have to work with ssl certificates and php, and just being able to fetch the html of this page to feed into the mPDF function
What about the $kirby->render() mode? Why is it throwing an error?
Also, I can’t find any documentation about it.
Yes, I can probably use AJAX for this as well (which I never used before tbh), just was trying to avoid extra overheads and keep it as basic as possible. I have the feeling AJAX might throw some CORS problem or some SSL-related hiccups.
so the kirby()->render() works perfectly in certain pages, and not in others. i debugged a bit, changing bits here and there and see if it was making a difference, but it seems it doesn’t and i have no clear idea of why it is like this.