<p>You're really fighting against the way Craft CMS does things. </p>

<p>I'd start by having a good read through the <a href="https://craftcms.com/docs/introduction" rel="nofollow noreferrer">Craft Docs</a> first, there really isn't a shortcut. The docs are really great though, and contain everything you're likely to need.</p>

<p>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. </p>

<p>Craft actually uses the <a href="http://twig.sensiolabs.org/doc/2.x/intro.html" rel="nofollow noreferrer">Twig</a> tempting language, which is really easy to get going with.</p>

<p>In answer to your specific question...</p>

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

<p>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 <a href="https://craftcms.com/docs/templating/craft.entries" rel="nofollow noreferrer">this page</a> to see how you'd go about it. You'd input your data via the Control Panel, so have a read <a href="https://craftcms.com/docs/sections-and-entries" rel="nofollow noreferrer">here</a> for that.</p>

CC BY-SA 3.0
2017-03-06T12:22:46.910Z
Hi Steve, thank you very much for your response! I feared you would say that :-P... In short, one of my developers has already built the page required and linked it into Craft and I am essentially trying to take his code and implement it into my framework. Unfortunately I don't think this is going to work... So, my next solution is to port my entire website to Laravel (something I have been meaning to do), and then implement Craft properly with Laravel (if this is possible). Hopefully this will make the whole process a lot easier :-)
Ben Carey
CC BY-SA 3.0
2017-03-06T12:24:50.517Z
Just before I mark the answer as accepted, could you possibly tell me if you have any experience with implementing Craft with Laravel? If so, is the process smooth or does it require dirty fixes and hacks? All of which I would be willing to do but I am so limited on time I need to ensure I pick the right path...
Ben Carey
CC BY-SA 3.0
2017-03-06T12:37:39.580Z
Hi Ben, I don't have any direct experience with Laravel, but I see no reason you can't integrate the two. Without a bit more info of what's in your Laravel App and what you want from Craft, it'd a bit tricky to say. It comes down to whether you want a Craft CMS site with some extra functionality, or a Laravel-centric site with a Craft CMS blog bolted on. If there isn't too much real integration you could either sit the Craft CMS part in a sub-directory of the Laravel site, or vice-versa.
Steve Holland
CC BY-SA 3.0
2017-03-06T15:03:38.313Z
``[Do] you want a Craft site or a Laravel-centric site w/ a Craft CMS blog bolted on?`` Bingo Steve.  I think that can really go into part of your answer above as well, it drives home what I think a lot of people new to this are struggling with.   

I have nothing to add to this answer but Ben you might want to look into [Template Hooks](https://craftcms.com/classreference/services/TemplatesService#hook-detail). Those will allow you to call whatever PHP code inside a Craft template, which might be useful when bringing your existing header/footer in.
RitterKnight
CC BY-SA 3.0
2017-03-06T12:14:31.527Z
2017-03-06T12:20:12.523Z
2017-03-06T12:20:12.523Z
Steve Holland
<p>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...</p>

<p>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.</p>

<p>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:</p>

<ol>
<li>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: <code>$blog_posts = $craft-&gt;getBlogPosts()</code></li>
<li>If not, is there a way to include certain files at the beginning and end of templates that are outside the craft directory?</li>
</ol>

<p>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 <code>head</code> 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.</p>

<p>This is what I currently have:</p>

<pre><code>// 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');
</code></pre>

<templating><php><include>
Use pure PHP and HTML instead of Templates
# Use pure PHP and HTML instead of Templates

(Asked by: username_0 on 2017-03-04)

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

**Tags:** templating, php, include

---

## 1 answers

### Answer by username_1 on 2017-03-06. Score: 4 | Accepted answer

You're really fighting against the way Craft CMS does things.

I'd start by having a good read through the [Craft Docs](https://craftcms.com/docs/introduction) 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 & PHP, but not so different that's it going to take you too long to figure it out.

Craft actually uses the [Twig](http://twig.sensiolabs.org/doc/2.x/intro.html) 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](https://craftcms.com/docs/templating/craft.entries) to see how you'd go about it. You'd input your data via the Control Panel, so have a read [here](https://craftcms.com/docs/sections-and-entries) for that.

> **Comments:**
> **username_0**: Hi Steve, thank you very much for your response! I feared you would say that :-P... In short, one of my developers has already built the page required and linked it into Craft and I am essentially trying to take his code and implement it into my framework. Unfortunately I don't think this is going to work... So, my next solution is to port my entire website to Laravel (something I have been meaning to do), and then implement Craft properly with Laravel (if this is possible). Hopefully this will make the whole process a lot easier :-)  
> **username_0**: Just before I mark the answer as accepted, could you possibly tell me if you have any experience with implementing Craft with Laravel? If so, is the process smooth or does it require dirty fixes and hacks? All of which I would be willing to do but I am so limited on time I need to ensure I pick the right path...  
> **username_1**: Hi Ben, I don't have any direct experience with Laravel, but I see no reason you can't integrate the two. Without a bit more info of what's in your Laravel App and what you want from Craft, it'd a bit tricky to say. It comes down to whether you want a Craft CMS site with some extra functionality, or a Laravel-centric site with a Craft CMS blog bolted on. If there isn't too much real integration you could either sit the Craft CMS part in a sub-directory of the Laravel site, or vice-versa.  
> **username_2**: ``[Do] you want a Craft site or a Laravel-centric site w/ a Craft CMS blog bolted on?`` Bingo Steve.  I think that can really go into part of your answer above as well, it drives home what I think a lot of people new to this are struggling with.     I have nothing to add to this answer but Ben you might want to look into [Template Hooks](https://craftcms.com/classreference/services/TemplatesService#hook-detail). Those will allow you to call whatever PHP code inside a Craft template, which might be useful when bringing your existing header/footer in.  

---

