Store Community Support Documentation


I'm looking to include the contents of an html file in one of my templates using a variable, but when I create both elements, nothing happens. 

Example: I need a variable such as {{menu2}} to pull the contents from a file like menu2.html.php into layout.html

How can I do this? Any help would be greatly appreciated!

Thank you much! 

Last update on June 7, 11:11 am by Nativedragon11.

Of course I searched the forum first, and I found the most recent article about it in the developers documentation. But it doesn't mention which files the code goes in, and how to get the site to recognize it:

Do I have to create a controller in a controller folder to define the variable behavior, and a template in the view folder to define the variable look, before placing the variable in the layout template to show it on the front end? If so, how do you get the site to know that it's there? I don't want to create a whole app for a simple template element. Would I have to?

There's also an older article (v3) that explains it a bit more in-depth (, but still isn't clear about where the code would go. "And from the .html.php file"  could mean that the code mentioned gets pulled from .html.php into another file, or that the code mentioned was output by .html.php as a result of the code being in a class (not a controller?). It doesn't say what files would need to be created, with examples on where they would be placed. I just need some clarification. 

I was even looking into learning more about the template engine, and phpFox is using two? A custom one similar to Smarty, and Twig? Which would I need in this case? I'm so confused. :(

Last update on June 8, 6:48 pm by Nativedragon11.

Could I just use something simple like:

{{ include('menu2.html.php') }}

to pull the contents of menu2.html.php into my layout.html? If so, would I need an absolute url, or would it pull relative to the folder it is in?

Last update on June 8, 6:50 pm by Nativedragon11.

Update: since the documentation says phpFox uses Twig, I decided to try the Twig method:

{{ include('menu2.html.php') }}

and it just made my site go blank. :(

This is from the developers documentation here:

It looks to be exactly what I am looking for, but it isn't very in-depth so I need some clarification so that I can maybe get this finally working:


route('/foo', function() {

   // Loads HTML file from your apps /views folder

   return view('index.html', [
      'foo' => 'bar'


In this example our HTML index.html could look like

<h1>Hello World!</h1>

   {{ foo }}


In the above example:

Where would the code (the first block with the route and function) be placed to make this work?

Where is the second block (the one with {{ foo }} in the paragraph tags) supposed to be? It says that "our HTML index.html could look like" but, isn't index.html the location of the content that will be displayed by  {{ foo }}?

I am essentially just looking to:

1. Create a custom menu in a file called menu2.html.php

2. Display the contents of menu2.html.php in my theme's layout.html file using {{ menu2 }}

Is there a simple method that I am missing?

Last update on June 11, 6:27 pm by Nativedragon11.

I tried making a simple app via the admin panel, then I created a controller within it to see if I could even get the variable to display "hello world":

// Index controller must be child of \Phpfox_Component class.
classIndexControllerextends \Phpfox_Component
// Get phpFox core template service
$template = $this->template();
// assign variables to template
'menu2' => 'hello world',

but when I try to output the variable {{menu2}} nothing happens. :(

I just want the custom content in menu2.html.php to be displayed in my layout.html by using the variable {{ menu2 }} , but I can't even get a simple 'hello world' to display. Any help would be greatly appreciated!