Changing shared template of application
Your application would usually have a consistent look throughout all pages. This look is defined by a "shared" template. This template is used by the Api class and its content will appear on all pages produced by Agile Toolkit.
It was already mentioned that you can change or completely replace this template. You should, however, put some of the important tags back into the template, such as: Content, js_include, document_ready, page_title, and version. If you don't want certain tags to be displayed, comment them inside HTML, prevent them from being added or destroy() them after they are added.
At the time when defaultTemplate is called, some of the initialization has been done. You can rely on $this->page to determine which page is being requested and based on this information return name of the template. Below code will use templates/default/index.html instead of templates/default/shared.html for the index page.
Do not confuse this with page templates. This replaces API templates and should not be located inside "page" folder.
... then function layout_Content in API will not be called and the pages will not be loaded silently. That is the correct behaviour and allows you to initialize only the sections of the layout which present in the template.
You can define other sections like this too. Use $this->addLayout('Sidebar'); inside API->init(); and then define layout_Sidebar() function in API. This function will only be called if region Sidebar is found in the template.
Conditioning based on authentication status
defaultTemplate() is called before init(), therefore if you define any authentication in the application, it will not be ready yet by the time API's template is initialized.
If you need to change something on your pages for logged-in users, then do it inside initLayout() function by either adding views or adding login for or just manipulating API's template.