Initialize C5 in custom script

Permalink
Hey, how do I initialize C5 in custom PHP script? I have a script header_ajax.php that calls a part of C5 teamplate:
echo json_encode(include('elements/header_nav.php'));

My intents here - header_ajax.php should return html code of header when I call it via jQuery AJAX. Of cource without initializing C5 in my script I got error:
Fatal error:  Uncaught Error: Class 'GlobalArea' not found in C:\MyStuff\WORK\OpenServer\domains\phantomik\www\application\themes\phantomik\elements\header_nav.php:17
Stack trace:
#0 C:\MyStuff\WORK\OpenServer\domains\phantomik\www\application\themes\phantomik\header_ajax.php(2): include()
#1 {main}
  thrown in C:\MyStuff\WORK\OpenServer\domains\phantomik\www\application\themes\phantomik\elements\header_nav.php on line 17

 
MaestroMagnifico replied on at Permalink Reply
I solved this buy creating API page on site and template for it. In template I placed all my code and now I'm AJAXing this page by url. I also had problem with $_SESSION. In my custom script behind AJAX I had empty session. Of course I added session_start() at begining. Maybe it's because C5 storing session in some weird way, i dunno. Now it works.
MaestroMagnifico replied on at Permalink Reply
Guys, is there more ways to insert your PHP code on page? I used two so far:
1. Create custom block and add your code there, then place block on page.
2. Create template with you code and asign in to some page.
JohntheFish replied on at Permalink Best Answer Reply
JohntheFish
Some more:
3. Single pages
4. Concrete5 Events
5. Custom attributes
6. Overrides

All are covered to some extent by documentation and howtos