include on common template

102 views
Skip to first unread message

Mike Galon

unread,
Aug 6, 2012, 8:09:28 AM8/6/12
to h2o-temp...@googlegroups.com
Guys,

I have a base.php and a child.php, is it possible i can include let say menu.php on child.php

Example

base.php
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title></title>
<body>
{% block content %}{% endblock %}
</body>
</html>

child.php
{% extends 'base.php' %}

{% block content %}
lorem lorem
<!-- i want to add menu.php here -->
{% endblock %}

menu.php
{% block menu %}
<ul>
<li>menu 1</li>
<li>menu 2</li>
</ul>
{% endblock %}

i tried adding {% extends 'menu.php' %} but i get an error, i also tried {% include "menu.php" %} :(

Thanks,

Mike

etor...@gmail.com

unread,
May 10, 2013, 2:03:14 PM5/10/13
to h2o-temp...@googlegroups.com
Hello, Mike.

I wonder the same thing.
Guess h2o inclusion model is different.
Pity there are still no qualified replies here.

daph...@gmail.com

unread,
Jan 30, 2014, 2:30:45 AM1/30/14
to h2o-temp...@googlegroups.com
{% extends %} should work if you extend child.php from menu.php. To do it the other way (as you put on this example), I have done it like this:

$menu= file_get_contents(menu.php');

This of course from the PHP file. Then, I send this variable in the template array, and print it with the {{menu}} variable where I want it.

I don't know if there is a better template-direct way to do it, but for now, this has worked for me.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages