Use pure PHP and HTML instead of Templates This is probably a very naive question but I am brand new to Craft and as such, have no idea what to research and where...

I have a static website that is built with my own bespoke framework. We have recently decided to add a 'blog' page to this website and resultantly, I am exploring using Craft in order to save me time writing a bespoke solution from scratch.

From what I can see, Craft is extremely flexible and brilliant for professional developers like myself who refuse to work with the likes of WordPress. However, implementing into my framework may just be a step too far in regards to flexibility. Quite simply, I would like to know the following:


Does craft allow me to make calls to get the stored data and then I manually handle the inserting of this data? e.g. Something like: $blog_posts = $craft-&gt;getBlogPosts()
If not, is there a way to include certain files at the beginning and end of templates that are outside the craft directory?


Basically, one of the key features of my framework is to handle the generation of all of the JavaScript and CSS links, along with the head section of each of the pages throughout my site. Based on what I have tested, I have managed to get the header working by just adding a PHP 'include' above the craft code in my file, however, the footer (including javascript) does not work because the Craft obviously has some sort of 'exit' call to prevent the code from executing further.

This is what I currently have:

// Define any custom javascript files and css files to be included in the cache
//...

// Generate the document header
include($_PATHS['CURRENT'].'/_includes/_content/header.php');

/*
 * Craft CMS Code to load the blog template
 */

// Path to your craft/ folder
$craftPath = './_craft/';

// Do not edit below this line
$path = rtrim($craftPath, '/').'/app/index.php';

if (!is_file($path))
{
    if (function_exists('http_response_code'))
    {
        http_response_code(503);
    }

    exit('Could not find your craft/ folder. Please ensure that &lt;strong&gt;&lt;code&gt;$craftPath&lt;/code&gt;&lt;/strong&gt; is set correctly in '.__FILE__);
}

require_once $path;

/*
 * End of Craft CMS Code
 */

// THIS DOES NOT WORK
// Generate the document footer
include($_PATHS['CURRENT'].'/_includes/_content/footer.php');
You're really fighting against the way Craft CMS does things. 

I'd start by having a good read through the Craft Docs first, there really isn't a shortcut. The docs are really great though, and contain everything you're likely to need.

Then, I'd set up a copy of Craft in isolation of your site/framework and just get a feel for how you do things the "Craft way". It is different to just doing HTML &amp; PHP, but not so different that's it going to take you too long to figure it out. 

Craft actually uses the Twig tempting language, which is really easy to get going with.

In answer to your specific question...

Does craft allow me to make calls to get the stored data and then I manually handle the inserting of this data?

Yes it does. To output your data, you'd likely use sections/entries in your Twig template. So take a look at the example at the top of this page to see how you'd go about it. You'd input your data via the Control Panel, so have a read here for that.