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->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 <strong><code>$craftPath</code></strong> 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');