How do I insert php code at the top of a template.

John Turner's Avatar

John Turner

25 May, 2010 07:15 PM

How do I insert php code at the top of a template before the document declaration. My code keeps getting stripped out.

  1. 1 Posted by Bradley Wagner on 25 May, 2010 07:45 PM

    Bradley Wagner's Avatar

    Try using a START-ROOT-CODE section.

    The template parser doesn't like unrecognized tags that look like XML processing instructions:

    <?php ... ?>
    

    Your template would look something like this:

    <?xml version="1.0"?>
    <html>
        <!--#START-ROOT-CODE
            <?php ... my php ...?>
        #END-ROOT-CODE-->
        .... rest of template ...
    </html>
    

    and would move the php to the top when rendering the page for publishing.

  2. Bradley Wagner closed this discussion on 25 May, 2010 07:45 PM.

  3. John Turner re-opened this discussion on 25 May, 2010 08:09 PM

  4. 2 Posted by John Turner on 25 May, 2010 08:09 PM

    John Turner's Avatar

    that's what I was looking for :) thx!

  5. Joel closed this discussion on 26 May, 2010 02:14 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac