Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combining inheritance and composition #6

Open
ejunker opened this issue May 27, 2010 · 1 comment
Open

Combining inheritance and composition #6

ejunker opened this issue May 27, 2010 · 1 comment

Comments

@ejunker
Copy link

ejunker commented May 27, 2010

Is there a way to use the old-style composition of having a separate header and footer file with inheritance? I want to create a base layout and include a header and footer where the header may have blocks in it and the base layout file also has blocks in it.

Here is an example:

base.php

<?php
  require_once 'ti.php';
  include 'header.php';
  emptyblock('content');
  include 'footer.php';
?>

header.php

<html>
  <head>
    <?php emptyblock('head') ?>
  </head>
  <body>

footer.php

  </body>
</html>

page.php

<?php include 'base.php' ?>

<?php startblock('head') ?>
  This is in the head
<?php endblock() ?>

<?php startblock('content') ?>
  This is the content
<?php endblock() ?>

After the content

The output for page.php is:


This is the head


After the content

As you see it has problems when it encounters the emptyblock('content') in base.php. If I comment out the emptyblock('content') I get this output:


This is the head

  </body>
</html>
After the content

This time it was able to render the footer.

Is there anyway to get the first example to work or is phpti not designed to handle that case?

@arshaw
Copy link
Owner

arshaw commented May 29, 2010

hmm, when i made the blockbase() function, i thought i had this scenario in mind, but after testing, it doesnt work (i tried putting blockbase() right after the require_once for ti.php)

i'll try to get this working in the next version. thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants