ahem...

Yes, if I use a PHP file using program code, then everything works just fine!

That was the very obvious part that I was missing! I knew it was something obvious. But that step wasn't made obvious in either the book I was using (PHP in Action by Manning: it's brilliant in parts, but a bit rushed and piecemeal in others...), or the PHPTAL documentation online. They just talk about the templates and the macro files, and don't seem to mention the vital step of creating a file that brings the files together...

Thank you very much for your help :-)

On 16 Jan 2009, at 15:00, Levi Stanley wrote:

Odd it works for me:

Output:

<html>


<body>
   <div>
       <h1>This is the external macro</h1>
   </div>    <div>
       <h1>This is the internal macro</h1>
   </div></body>

</html>


Program Code:

<?php
   include_once('PHPTAL.php');

   $template = new PHPTAL('page.html');

   try {
       print $template->execute();
   } catch ( Exception $e ){
       print "Error: {$e->getMessage()}\n";
   }

?>


Pete Loggie wrote:
I included the complete code I'm testing in the original post. It's as
simple as it can be:

macro.html
<html>

   <div metal:define-macro="external">
       <h1>This is the external macro</h1>
   </div>

</html>

page.html
<html>
   <div metal:define-macro="internal">
       <h1>This is the internal macro</h1>
   </div>

<body>
   <span metal:use-macro="macro.html/external"/>
   <span metal:use-macro="internal"/>
</body>

</html>

If I prefix the internal macro with the current filename, it still
works...



On 16 Jan 2009, at 14:08, Christoph Frick wrote:

On Fri, Jan 16, 2009 at 02:02:06PM -0200, Pete Loggie wrote:

No, I don't get any error messages... All that happens is the external
macro isn't displayed. It's such a basic issue, that I have no idea
what the problem might be. I mean, if internal macros work fine, then that suggests that PHPTAL is half-working. But the external ones, they
just ...  don't do anything :-S All rather frustrating.

then its more likely you macro does some tal:condition right at the
beginning and therefor simply does not get executed? do you use some
kind of tal:block="" syntax there?

you could try to call the macro with the file name prefixed but from the
current file. e.g:

test.xhtml:

<metal:macro metal:define-macro="test">
<h1>hello world</h1>
</metal:macro>
<metal:macro metal:use-macro="test.xhtml/test"/>

--
cu
_______________________________________________
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal


_______________________________________________
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal



_______________________________________________
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal


_______________________________________________
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal

Reply via email to